aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-08-13 01:55:56 +0200
committerdec05eba <dec05eba@protonmail.com>2023-08-13 01:55:56 +0200
commita253be38b789385e2a04bd1deff5623980ed67e2 (patch)
tree3c49250645d34648a204ba0dd7c2c0bafe4ce1ff
parent26b54ff3e4507c51ef113c1a028305de0a520981 (diff)
kms vaapi: fix capture bug (incorrect video size) caused by shadowed variable...
-rwxr-xr-xbuild.sh4
-rw-r--r--src/capture/kms_vaapi.c18
-rw-r--r--src/main.cpp2
-rw-r--r--src/utils.c4
4 files changed, 9 insertions, 19 deletions
diff --git a/build.sh b/build.sh
index 28db825..6b3e35c 100755
--- a/build.sh
+++ b/build.sh
@@ -6,8 +6,8 @@ cd "$script_dir"
CC=${CC:-gcc}
CXX=${CXX:-g++}
-opts="-O2 -g0 -DNDEBUG -Wall -Wextra"
-[ -n "$DEBUG" ] && opts="-O0 -g3 -Wall -Wextra";
+opts="-O2 -g0 -DNDEBUG -Wall -Wextra -Wshadow"
+[ -n "$DEBUG" ] && opts="-O0 -g3 -Wall -Wextra -Wshadow";
build_wayland_protocol() {
wayland-scanner private-code external/wlr-export-dmabuf-unstable-v1.xml external/wlr-export-dmabuf-unstable-v1-protocol.c
diff --git a/src/capture/kms_vaapi.c b/src/capture/kms_vaapi.c
index b734e6c..8e1a693 100644
--- a/src/capture/kms_vaapi.c
+++ b/src/capture/kms_vaapi.c
@@ -164,16 +164,12 @@ static int gsr_capture_kms_vaapi_start(gsr_capture *cap, AVCodecContext *video_c
cap_kms->capture_pos = monitor.pos;
cap_kms->capture_size = monitor.size;
- fprintf(stderr, "capture size: %d, %d\n", cap_kms->capture_size.x, cap_kms->capture_size.y);
-
/* Disable vsync */
cap_kms->params.egl->eglSwapInterval(cap_kms->params.egl->egl_display, 0);
video_codec_context->width = max_int(2, even_number_ceil(cap_kms->capture_size.x));
video_codec_context->height = max_int(2, even_number_ceil(cap_kms->capture_size.y));
- fprintf(stderr, "video size: %d, %d\n", video_codec_context->width, video_codec_context->height);
-
if(!drm_create_codec_context(cap_kms, video_codec_context)) {
gsr_capture_kms_vaapi_stop(cap, video_codec_context);
return -1;
@@ -468,12 +464,6 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
if(!capture_is_combined_plane && cursor_drm_fd && cursor_drm_fd->connector_id != drm_fd->connector_id)
cursor_drm_fd = NULL;
- static bool test = true;
- if(test) {
- test = false;
- fprintf(stderr, "drm fd: %u, %u\n", drm_fd->width, drm_fd->height);
- }
-
// TODO: This causes a crash sometimes on steam deck, why? is it a driver bug? a vaapi pure version doesn't cause a crash.
// Even ffmpeg kmsgrab causes this crash. The error is:
// amdgpu: Failed to allocate a buffer:
@@ -530,7 +520,7 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
texture_rotation);
if(cursor_drm_fd) {
- const intptr_t img_attr[] = {
+ const intptr_t img_attr_cursor[] = {
EGL_LINUX_DRM_FOURCC_EXT, cursor_drm_fd->pixel_format,
EGL_WIDTH, cursor_drm_fd->width,
EGL_HEIGHT, cursor_drm_fd->height,
@@ -542,10 +532,10 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) {
EGL_NONE
};
- EGLImage image = cap_kms->params.egl->eglCreateImage(cap_kms->params.egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr);
+ EGLImage cursor_image = cap_kms->params.egl->eglCreateImage(cap_kms->params.egl->egl_display, 0, EGL_LINUX_DMA_BUF_EXT, NULL, img_attr_cursor);
cap_kms->params.egl->glBindTexture(GL_TEXTURE_2D, cap_kms->cursor_texture);
- cap_kms->params.egl->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
- cap_kms->params.egl->eglDestroyImage(cap_kms->params.egl->egl_display, image);
+ cap_kms->params.egl->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, cursor_image);
+ cap_kms->params.egl->eglDestroyImage(cap_kms->params.egl->egl_display, cursor_image);
cap_kms->params.egl->glBindTexture(GL_TEXTURE_2D, 0);
vec2i cursor_size = {cursor_drm_fd->width, cursor_drm_fd->height};
diff --git a/src/main.cpp b/src/main.cpp
index 886ae25..42a7012 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -930,7 +930,7 @@ static void save_replay_async(AVCodecContext *video_codec_context, int video_str
av_packet.stream_index = stream->index;
av_packet_rescale_ts(&av_packet, codec_context->time_base, stream->time_base);
- int ret = av_write_frame(av_format_context, &av_packet);
+ ret = av_write_frame(av_format_context, &av_packet);
if(ret < 0)
fprintf(stderr, "Error: Failed to write frame index %d to muxer, reason: %s (%d)\n", stream->index, av_error_to_string(ret), ret);
diff --git a/src/utils.c b/src/utils.c
index 16e928a..db0bd6f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -275,8 +275,8 @@ bool gsr_get_valid_card_path(char *output) {
if(!planes)
goto next;
- for(uint32_t i = 0; i < planes->count_planes; ++i) {
- drmModePlanePtr plane = drmModeGetPlane(fd, planes->planes[i]);
+ for(uint32_t j = 0; j < planes->count_planes; ++j) {
+ drmModePlanePtr plane = drmModeGetPlane(fd, planes->planes[j]);
if(!plane)
continue;