@@ -263,22 +263,25 @@ static const char* detectCodecByVaX11(FFVAData* vaData, FFCodecOptions* options,
263263 FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libX11 , XOpenDisplay )
264264 FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libX11 , XCloseDisplay )
265265
266+ FF_LIBRARY_LOAD_MESSAGE (libvaX11 , "libva-x11" FF_LIBRARY_EXTENSION , 2 )
267+ FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libvaX11 , vaGetDisplay )
268+
266269 Display * x11Display = ffXOpenDisplay (NULL );
267270 if (!x11Display ) {
268271 return "XOpenDisplay() failed" ;
269272 }
270273
271- FF_LIBRARY_LOAD_MESSAGE (libvaX11 , "libva-x11" FF_LIBRARY_EXTENSION , 2 )
272- FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libvaX11 , vaGetDisplay )
273-
274274 VADisplay display = ffvaGetDisplay (x11Display );
275275 if (!display ) {
276+ ffXCloseDisplay (x11Display );
276277 return "vaGetDisplay() failed" ;
277278 }
278279
279280 if (!vaDetectDisplay (display , vaData , options , result , "VA-API (X11)" )) {
281+ ffXCloseDisplay (x11Display );
280282 return "VA-API could not detect any supported codec via X11" ;
281283 }
284+ ffXCloseDisplay (x11Display );
282285
283286 return NULL ;
284287}
@@ -372,14 +375,14 @@ static const char* detectCodecByVdpau(FFCodecOptions* options, FFlist* result) {
372375 FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libX11 , XCloseDisplay )
373376 FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libX11 , XDefaultScreen )
374377
378+ FF_LIBRARY_LOAD_MESSAGE (libvdpau , "libvdpau" FF_LIBRARY_EXTENSION , 1 )
379+ FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libvdpau , vdp_device_create_x11 )
380+
375381 Display * x11Display = ffXOpenDisplay (NULL );
376382 if (!x11Display ) {
377383 return "XOpenDisplay() failed" ;
378384 }
379385
380- FF_LIBRARY_LOAD_MESSAGE (libvdpau , "libvdpau" FF_LIBRARY_EXTENSION , 1 )
381- FF_LIBRARY_LOAD_SYMBOL_MESSAGE (libvdpau , vdp_device_create_x11 )
382-
383386 VdpDevice device = VDP_INVALID_HANDLE ;
384387 VdpGetProcAddress * ffvdp_get_proc_address = NULL ;
385388 if (ffvdp_device_create_x11 (x11Display , ffXDefaultScreen (x11Display ), & device , & ffvdp_get_proc_address ) != VDP_STATUS_OK ||
0 commit comments