mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 14:35:57 +01:00
screencast: use the pipewire callback process to start screencast
We can trigger that with pw_stream_trigger_process when we are the driver of the stream. Additionally this let's us run passivly with the consumer driving the stream.
This commit is contained in:
parent
7b3a17bae0
commit
b2f1a10023
3 changed files with 23 additions and 4 deletions
|
@ -6,6 +6,8 @@
|
|||
#define XDPW_PWR_BUFFERS 1
|
||||
#define XDPW_PWR_ALIGN 16
|
||||
|
||||
void xdpw_pwr_trigger_process(struct xdpw_screencast_instance *cast);
|
||||
bool xdpw_pwr_is_driving(struct xdpw_screencast_instance *cast);
|
||||
void xdpw_pwr_dequeue_buffer(struct xdpw_screencast_instance *cast);
|
||||
void xdpw_pwr_enqueue_buffer(struct xdpw_screencast_instance *cast);
|
||||
void pwr_update_stream_param(struct xdpw_screencast_instance *cast);
|
||||
|
|
|
@ -44,6 +44,14 @@ static struct spa_pod *build_format(struct spa_pod_builder *b, enum spa_video_fo
|
|||
return spa_pod_builder_pop(b, &f[0]);
|
||||
}
|
||||
|
||||
static void pwr_handle_stream_process(void *data) {
|
||||
struct xdpw_screencast_instance *cast = data;
|
||||
|
||||
logprint(TRACE, "pipewire: stream process");
|
||||
|
||||
xdpw_wlr_frame_start(cast);
|
||||
}
|
||||
|
||||
static void pwr_handle_stream_state_changed(void *data,
|
||||
enum pw_stream_state old, enum pw_stream_state state, const char *error) {
|
||||
struct xdpw_screencast_instance *cast = data;
|
||||
|
@ -176,8 +184,17 @@ static const struct pw_stream_events pwr_stream_events = {
|
|||
.param_changed = pwr_handle_stream_param_changed,
|
||||
.add_buffer = pwr_handle_stream_add_buffer,
|
||||
.remove_buffer = pwr_handle_stream_remove_buffer,
|
||||
.process = pwr_handle_stream_process,
|
||||
};
|
||||
|
||||
void xdpw_pwr_trigger_process(struct xdpw_screencast_instance *cast) {
|
||||
pw_stream_trigger_process(cast->stream);
|
||||
}
|
||||
|
||||
bool xdpw_pwr_is_driving(struct xdpw_screencast_instance *cast) {
|
||||
return pw_stream_is_driving(cast->stream);
|
||||
}
|
||||
|
||||
void xdpw_pwr_dequeue_buffer(struct xdpw_screencast_instance *cast) {
|
||||
logprint(TRACE, "pipewire: dequeueing buffer");
|
||||
|
||||
|
|
|
@ -53,17 +53,17 @@ void xdpw_wlr_frame_finish(struct xdpw_screencast_instance *cast) {
|
|||
return ;
|
||||
}
|
||||
|
||||
if (cast->pwr_stream_state) {
|
||||
if (cast->pwr_stream_state && xdpw_pwr_is_driving(cast)) {
|
||||
if (cast->frame_state == XDPW_FRAME_STATE_SUCCESS) {
|
||||
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_frame_start, cast);
|
||||
(xdpw_event_loop_timer_func_t) xdpw_pwr_trigger_process, cast);
|
||||
} else {
|
||||
xdpw_wlr_frame_start(cast);
|
||||
xdpw_pwr_trigger_process(cast);
|
||||
}
|
||||
} else {
|
||||
xdpw_wlr_frame_start(cast);
|
||||
xdpw_pwr_trigger_process(cast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue