aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/recorder/screenshot.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2026-08-02 01:11:33 +0200
committerdec05eba <dec05eba@protonmail.com>2026-08-02 01:11:53 +0200
commitd72113be395891f4289f0d86a32a37a99a4d5b38 (patch)
treec2dd74d24fe62d1020be64980b8a321e999bcc29 /src/recorder/screenshot.c
parentb38d324c8fcb61b699a16c39fc0dcdb31ad9934b (diff)
Add -ipc option to control gpu-screen-recorder over a unix domain socket
The socket accepts the same commands as the signal handlers, except that saving a replay takes an arbitrary number of seconds instead of only the fixed times that the signals provide. Requests and replies are newline terminated json objects and every request is replied to, parsed with the sj.h json library that was added to external. Requests are handled on a thread that only runs while the recorder exists, so the recorder control fields are now atomics, which they have to be now that another thread writes them.
Diffstat (limited to 'src/recorder/screenshot.c')
-rw-r--r--src/recorder/screenshot.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/recorder/screenshot.c b/src/recorder/screenshot.c
index 47fedef..2e4357d 100644
--- a/src/recorder/screenshot.c
+++ b/src/recorder/screenshot.c
@@ -67,7 +67,7 @@ int gsr_screenshot_take(const gsr_screenshot_params *params) {
gsr_window *window = params->window;
gsr_capture_deps *capture_deps = params->capture_deps;
gsr_capture_sources *capture_sources = params->capture_sources;
- const volatile sig_atomic_t *running = params->running;
+ const atomic_int *running = params->running;
const int image_quality = video_quality_to_image_quality_value(settings->video_quality);
const gsr_color_range color_range = image_format_to_color_range(params->image_format, image_quality);
@@ -122,7 +122,7 @@ int gsr_screenshot_take(const gsr_screenshot_params *params) {
bool should_stop_error = false;
egl->glClear(0);
- while(*running) {
+ while(atomic_load(running)) {
while(gsr_window_process_event(window)) {
if(capture_deps->x11_cursor_display && settings->record_cursor)
gsr_cursor_on_event(&capture_deps->x11_cursor, gsr_window_get_event_data(window));
@@ -175,7 +175,7 @@ int gsr_screenshot_take(const gsr_screenshot_params *params) {
if(all_sources_captured)
break;
- if(*running)
+ if(atomic_load(running))
usleep(30 * 1000); // 30 ms
}