From 6d75615e1d431510fbdd29072134f82b9b6b7e16 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 10 Apr 2023 23:03:52 +0200 Subject: aaa --- src/capture/kms_vaapi.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/capture/kms_vaapi.c b/src/capture/kms_vaapi.c index 3e54a5b..fe66ace 100644 --- a/src/capture/kms_vaapi.c +++ b/src/capture/kms_vaapi.c @@ -174,8 +174,6 @@ static void gsr_capture_kms_vaapi_tick(gsr_capture *cap, AVCodecContext *video_c return; } - VASurfaceID target_surface_id = (uintptr_t)(*frame)->data[3]; - VAStatus va_status = vaCreateConfig(cap_kms->va_dpy, VAProfileNone, VAEntrypointVideoProc, NULL, 0, &cap_kms->config_id); if(va_status != VA_STATUS_SUCCESS) { fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_tick: vaCreateConfig failed: %d\n", va_status); @@ -183,14 +181,6 @@ static void gsr_capture_kms_vaapi_tick(gsr_capture *cap, AVCodecContext *video_c cap_kms->stop_is_error = true; return; } - - va_status = vaCreateContext(cap_kms->va_dpy, cap_kms->config_id, cap_kms->kms_size.x, cap_kms->kms_size.y, VA_PROGRESSIVE, &target_surface_id, 1, &cap_kms->context_id); - if(va_status != VA_STATUS_SUCCESS) { - fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_tick: vaCreateContext failed: %d\n", va_status); - cap_kms->should_stop = true; - cap_kms->stop_is_error = true; - return; - } } } @@ -235,6 +225,19 @@ static int gsr_capture_kms_vaapi_capture(gsr_capture *cap, AVFrame *frame) { cap_kms->kms_size.x = kms_response.data.fd.width; cap_kms->kms_size.y = kms_response.data.fd.height; + static bool cc = false; + if(!cc) { + cc = true; + + VAStatus va_status = vaCreateContext(cap_kms->va_dpy, cap_kms->config_id, cap_kms->kms_size.x, cap_kms->kms_size.y, VA_PROGRESSIVE, &target_surface_id, 1, &cap_kms->context_id); + if(va_status != VA_STATUS_SUCCESS) { + fprintf(stderr, "gsr error: gsr_capture_kms_vaapi_capture: vaCreateContext failed: %d\n", va_status); + cap_kms->should_stop = true; + cap_kms->stop_is_error = true; + return -1; + } + } + if(cap_kms->buffer_id) { vaDestroyBuffer(cap_kms->va_dpy, cap_kms->buffer_id); cap_kms->buffer_id = 0; -- cgit v1.2.3