aboutsummaryrefslogtreecommitdiff
path: root/src/capture/kms_cuda.c
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-02-09 00:38:23 +0100
committerdec05eba <dec05eba@protonmail.com>2024-02-09 00:38:23 +0100
commitac73d9cb13ea7e4694b6b013de426cefddae4ca7 (patch)
tree28ea2dcea83e1d5717110b00b4349f09c8af0f3b /src/capture/kms_cuda.c
parent3eb7bae12c9fe50913a57656d2b324d4da18c30a (diff)
Remove wayland capture (wlroots)
Diffstat (limited to 'src/capture/kms_cuda.c')
-rw-r--r--src/capture/kms_cuda.c117
1 files changed, 40 insertions, 77 deletions
diff --git a/src/capture/kms_cuda.c b/src/capture/kms_cuda.c
index a7e991b..f5b96a8 100644
--- a/src/capture/kms_cuda.c
+++ b/src/capture/kms_cuda.c
@@ -37,8 +37,6 @@ typedef struct {
gsr_kms_client kms_client;
gsr_kms_response kms_response;
- gsr_kms_response_fd wayland_kms_data;
- bool using_wayland_capture;
vec2i capture_pos;
vec2i capture_size;
@@ -144,32 +142,24 @@ static int gsr_capture_kms_cuda_start(gsr_capture *cap, AVCodecContext *video_co
gsr_monitor monitor;
cap_kms->monitor_id.num_connector_ids = 0;
- if(gsr_egl_start_capture(cap_kms->params.egl, cap_kms->params.display_to_capture)) {
- if(!get_monitor_by_name(cap_kms->params.egl, GSR_CONNECTION_WAYLAND, cap_kms->params.display_to_capture, &monitor)) {
- fprintf(stderr, "gsr error: gsr_capture_kms_cuda_start: failed to find monitor by name \"%s\"\n", cap_kms->params.display_to_capture);
- gsr_capture_kms_cuda_stop(cap, video_codec_context);
- return -1;
- }
- cap_kms->using_wayland_capture = true;
- } else {
- int kms_init_res = gsr_kms_client_init(&cap_kms->kms_client, cap_kms->params.egl->card_path);
- if(kms_init_res != 0) {
- gsr_capture_kms_cuda_stop(cap, video_codec_context);
- return kms_init_res;
- }
- MonitorCallbackUserdata monitor_callback_userdata = {
- cap_kms,
- cap_kms->params.display_to_capture, strlen(cap_kms->params.display_to_capture),
- 0
- };
- for_each_active_monitor_output(cap_kms->params.egl, GSR_CONNECTION_DRM, monitor_callback, &monitor_callback_userdata);
+ int kms_init_res = gsr_kms_client_init(&cap_kms->kms_client, cap_kms->params.egl->card_path);
+ if(kms_init_res != 0) {
+ gsr_capture_kms_cuda_stop(cap, video_codec_context);
+ return kms_init_res;
+ }
- if(!get_monitor_by_name(cap_kms->params.egl, GSR_CONNECTION_DRM, cap_kms->params.display_to_capture, &monitor)) {
- fprintf(stderr, "gsr error: gsr_capture_kms_cuda_start: failed to find monitor by name \"%s\"\n", cap_kms->params.display_to_capture);
- gsr_capture_kms_cuda_stop(cap, video_codec_context);
- return -1;
- }
+ MonitorCallbackUserdata monitor_callback_userdata = {
+ cap_kms,
+ cap_kms->params.display_to_capture, strlen(cap_kms->params.display_to_capture),
+ 0
+ };
+ for_each_active_monitor_output(cap_kms->params.egl, GSR_CONNECTION_DRM, monitor_callback, &monitor_callback_userdata);
+
+ if(!get_monitor_by_name(cap_kms->params.egl, GSR_CONNECTION_DRM, cap_kms->params.display_to_capture, &monitor)) {
+ fprintf(stderr, "gsr error: gsr_capture_kms_cuda_start: failed to find monitor by name \"%s\"\n", cap_kms->params.display_to_capture);
+ gsr_capture_kms_cuda_stop(cap, video_codec_context);
+ return -1;
}
cap_kms->capture_pos = monitor.pos;
@@ -407,62 +397,37 @@ static int gsr_capture_kms_cuda_capture(gsr_capture *cap, AVFrame *frame) {
gsr_kms_response_fd *drm_fd = NULL;
gsr_kms_response_fd *cursor_drm_fd = NULL;
bool capture_is_combined_plane = false;
- if(cap_kms->using_wayland_capture) {
- gsr_egl_update(cap_kms->params.egl);
- cap_kms->wayland_kms_data.fd = cap_kms->params.egl->fd;
- cap_kms->wayland_kms_data.width = cap_kms->params.egl->width;
- cap_kms->wayland_kms_data.height = cap_kms->params.egl->height;
- cap_kms->wayland_kms_data.pitch = cap_kms->params.egl->pitch;
- cap_kms->wayland_kms_data.offset = cap_kms->params.egl->offset;
- cap_kms->wayland_kms_data.pixel_format = cap_kms->params.egl->pixel_format;
- cap_kms->wayland_kms_data.modifier = cap_kms->params.egl->modifier;
- cap_kms->wayland_kms_data.connector_id = 0;
- cap_kms->wayland_kms_data.is_combined_plane = false;
- cap_kms->wayland_kms_data.is_cursor = false;
- cap_kms->wayland_kms_data.x = cap_kms->wayland_kms_data.x; // TODO: Use these
- cap_kms->wayland_kms_data.y = cap_kms->wayland_kms_data.y;
- cap_kms->wayland_kms_data.src_w = cap_kms->wayland_kms_data.width;
- cap_kms->wayland_kms_data.src_h = cap_kms->wayland_kms_data.height;
-
- cap_kms->capture_pos.x = cap_kms->wayland_kms_data.x;
- cap_kms->capture_pos.y = cap_kms->wayland_kms_data.y;
-
- if(cap_kms->wayland_kms_data.fd <= 0)
- return -1;
-
- drm_fd = &cap_kms->wayland_kms_data;
- } else {
- if(gsr_kms_client_get_kms(&cap_kms->kms_client, &cap_kms->kms_response) != 0) {
- fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: failed to get kms, error: %d (%s)\n", cap_kms->kms_response.result, cap_kms->kms_response.err_msg);
- return -1;
- }
- if(cap_kms->kms_response.num_fds == 0) {
- static bool error_shown = false;
- if(!error_shown) {
- error_shown = true;
- fprintf(stderr, "gsr error: no drm found, capture will fail\n");
- }
- return -1;
- }
+ if(gsr_kms_client_get_kms(&cap_kms->kms_client, &cap_kms->kms_response) != 0) {
+ fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: failed to get kms, error: %d (%s)\n", cap_kms->kms_response.result, cap_kms->kms_response.err_msg);
+ return -1;
+ }
- for(int i = 0; i < cap_kms->monitor_id.num_connector_ids; ++i) {
- drm_fd = find_drm_by_connector_id(&cap_kms->kms_response, cap_kms->monitor_id.connector_ids[i]);
- if(drm_fd)
- break;
+ if(cap_kms->kms_response.num_fds == 0) {
+ static bool error_shown = false;
+ if(!error_shown) {
+ error_shown = true;
+ fprintf(stderr, "gsr error: no drm found, capture will fail\n");
}
+ return -1;
+ }
- // Will never happen on wayland unless the target monitor has been disconnected
- if(!drm_fd) {
- drm_fd = find_first_combined_drm(&cap_kms->kms_response);
- if(!drm_fd)
- drm_fd = find_largest_drm(&cap_kms->kms_response);
- capture_is_combined_plane = true;
- }
+ for(int i = 0; i < cap_kms->monitor_id.num_connector_ids; ++i) {
+ drm_fd = find_drm_by_connector_id(&cap_kms->kms_response, cap_kms->monitor_id.connector_ids[i]);
+ if(drm_fd)
+ break;
+ }
- cursor_drm_fd = find_cursor_drm(&cap_kms->kms_response);
+ // Will never happen on wayland unless the target monitor has been disconnected
+ if(!drm_fd) {
+ drm_fd = find_first_combined_drm(&cap_kms->kms_response);
+ if(!drm_fd)
+ drm_fd = find_largest_drm(&cap_kms->kms_response);
+ capture_is_combined_plane = true;
}
+ cursor_drm_fd = find_cursor_drm(&cap_kms->kms_response);
+
if(!drm_fd)
return -1;
@@ -551,8 +516,6 @@ static void gsr_capture_kms_cuda_capture_end(gsr_capture *cap, AVFrame *frame) {
(void)frame;
gsr_capture_kms_cuda *cap_kms = cap->priv;
- gsr_egl_cleanup_frame(cap_kms->params.egl);
-
for(int i = 0; i < cap_kms->kms_response.num_fds; ++i) {
if(cap_kms->kms_response.fds[i].fd > 0)
close(cap_kms->kms_response.fds[i].fd);