Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use pipewire buffers #141

Merged
merged 19 commits into from
Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2323296
screencast: pipewire add functions to dequeue and enqueue a buffer
columbarius May 27, 2021
5216916
screencast: use dequeue/enqueue functions instead of on_process event…
columbarius May 27, 2021
68d938f
screencast: remove pipewire on_event callback
columbarius May 27, 2021
5b8b189
screencast: pipewire add import_wl_shm_buffer function
columbarius May 27, 2021
e726cda
screencast: rename xdpw_frame into xdpw_screencopy_frame
columbarius Jun 16, 2021
444aac9
screencast: only restart wlroots loop if stream is active
columbarius Jun 16, 2021
d7cc408
screencast: implement buffer property checks wrt. xdpw_frame and xdpw…
columbarius Jun 16, 2021
c822461
screencast: use pipewire buffers directly for wlroots screencopy
columbarius Jun 16, 2021
5e69384
screencast: cleanup screencopy_frame
columbarius Jun 16, 2021
ff9965d
screencast: only end the fps measurement when it was started before
columbarius Jul 6, 2021
804920e
screencast: reorder screencopy callbacks
columbarius Aug 18, 2021
c4e98b8
screencast: introduce xdpw_frame_state and xdpw_wlr_stream_finish
columbarius Aug 18, 2021
a56312a
screencast: drop imported PipeWire buffer on remove_buffer
columbarius Nov 3, 2021
32b55d3
screencast: don't fail when copy_buffer was unsuccessfull
columbarius Nov 4, 2021
91c53a9
screencast: mark buffer as invalid when screencopy fails
columbarius Aug 18, 2021
ca00e96
screencast: use asserts for fatal errors
columbarius Aug 18, 2021
f5d62fc
meson: bump required pipewire version to 0.3.34
columbarius Sep 9, 2021
ac2c3fe
screencast: use the pipewire callback process to start screencast
columbarius Sep 9, 2021
b224a75
screencast: bump the prefered amount of pipewire buffers to 4
columbarius Sep 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/screencast/pipewire_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ static void pwr_handle_stream_state_changed(void *data,
switch (state) {
case PW_STREAM_STATE_STREAMING:
cast->pwr_stream_state = true;
if (!cast->wlr_frame) {
xdpw_wlr_register_cb(cast);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked every commit again and found a race condition only in screencast: only restart wlroots loop if stream is active
when PipeWire sends a state_changed changing the state to PW_STATE_STREAMING in between the buffer_done and the ready/failed events of the screencopy loop. This did trigger a new screencopy loop entrance while the old wasn't finished and triggered an assertion in xdpw_pwr_dequeue_buffer.

Checking if NO screencopy loop is currently running via cast->wlr_frame == NULL solved this issue.

break;
default:
cast->pwr_stream_state = false;
Expand Down
14 changes: 8 additions & 6 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ void xdpw_wlr_frame_free(struct xdpw_screencast_instance *cast) {
return ;
}

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);
} else {
xdpw_wlr_register_cb(cast);
if (cast->pwr_stream_state) {
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);
} else {
xdpw_wlr_register_cb(cast);
}
}
}

Expand Down