~ruther/guix-config

guix-config/patches/xdpw-wlr-screencopy-trigger-process.patch -rw-r--r-- 1.9 KiB
1fc2e5c4 — Rutherther feat(dwl): use mew as xdg-desktop-portal-wlr source chooser 7 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
diff --git a/src/screencast/wlr_screencopy.c b/src/screencast/wlr_screencopy.c
index 81beb9e..693ca4c 100644
--- a/src/screencast/wlr_screencopy.c
+++ b/src/screencast/wlr_screencopy.c
@@ -32,6 +32,14 @@ static void wlr_frame_finish(struct xdpw_screencast_instance *cast) {
 	logprint(TRACE, "wlroots: frame destroyed");
 }
 
+// Ends the current capture cycle: hand the buffer back to PipeWire and drop
+// the wlr frame. We drive the graph, so ask for the next cycle ourselves.
+static void wlr_frame_done(struct xdpw_screencast_instance *cast) {
+	xdpw_pwr_enqueue_buffer(cast);
+	wlr_frame_finish(cast);
+	pw_stream_trigger_process(cast->stream);
+}
+
 static void wlr_frame_buffer_done(void *data,
 		struct zwlr_screencopy_frame_v1 *frame);
 
@@ -137,16 +145,14 @@ static void wlr_frame_buffer_done(void *data,
 
 	if (!cast->current_frame.xdpw_buffer) {
 		logprint(WARN, "wlroots: no current buffer");
-		xdpw_pwr_enqueue_buffer(cast);
-		wlr_frame_finish(cast);
+		wlr_frame_done(cast);
 		return;
 	}
 
 	if (!check_constraints(&cast->current_constraints, cast->current_frame.xdpw_buffer)) {
 		logprint(DEBUG, "wlroots: buffer constraints changed");
 		pwr_update_stream_param(cast);
-		xdpw_pwr_enqueue_buffer(cast);
-		wlr_frame_finish(cast);
+		wlr_frame_done(cast);
 		return;
 	}
 
@@ -199,8 +205,7 @@ static void wlr_frame_ready(void *data, struct zwlr_screencopy_frame_v1 *frame,
 	cast->current_frame.completed = true;
 	logprint(TRACE, "wlroots: timestamp %"PRIu64":%"PRIu32, cast->current_frame.tv_sec, cast->current_frame.tv_nsec);
 
-	xdpw_pwr_enqueue_buffer(cast);
-	wlr_frame_finish(cast);
+	wlr_frame_done(cast);
 }
 
 static void wlr_frame_failed(void *data,
@@ -212,8 +217,7 @@ static void wlr_frame_failed(void *data,
 
 	logprint(TRACE, "wlroots: failed event handler");
 
-	xdpw_pwr_enqueue_buffer(cast);
-	wlr_frame_finish(cast);
+	wlr_frame_done(cast);
 }
 
 static const struct zwlr_screencopy_frame_v1_listener wlr_frame_listener = {