Skip to content
Snippets Groups Projects
Commit 9653b943 authored by Simon McVittie's avatar Simon McVittie
Browse files

check-va-api: Pair calls to vaDestroySurfaces() with create_surfaces()


Each test creates new surfaces and puts their IDs in the array `surfaces`,
and previously we only destroyed the surfaces created by the last test.
The result is that if we ran more than one test, the surfaces created
by earlier tests would be leaked.

For example, if the VA-API implementation does not support H264 but
does support MPEG, we would have leaked the pair of surfaces that were
created in order to test H264, but we would correctly destroy the pair
of surfaces that were created in order to test MPEG. Now we destroy both.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent f27daff0
Branches
Tags
1 merge request!801check-va-api: Use supported surface format + opportunistic cleanup
......@@ -52,6 +52,18 @@ clear_va_display (VADisplay *displayp)
clear_pointer (displayp, vaTerminate);
}
static void
clear_surfaces (VADisplay va_display,
VASurfaceID *surfaces,
int surfaces_count)
{
if (va_display && surfaces && surfaces[0] != VA_INVALID_SURFACE)
vaDestroySurfaces (va_display, surfaces, surfaces_count);
for (int i = 0; i < surfaces_count; i++)
surfaces[i] = VA_INVALID_SURFACE;
}
enum
{
OPTION_HELP = 1,
......@@ -443,6 +455,8 @@ out:
if (slice_data_buf != VA_INVALID_ID)
vaDestroyBuffer (va_display, slice_data_buf);
clear_surfaces (va_display, surfaces, surfaces_count);
return ret;
}
......@@ -524,6 +538,8 @@ out:
if (context != VA_INVALID_ID)
vaDestroyContext (va_display, context);
clear_surfaces (va_display, surfaces, surfaces_count);
return ret;
}
......@@ -645,11 +661,5 @@ main (int argc,
ret = 0;
out:
if (va_display)
{
if (surfaces && surfaces[0] != VA_INVALID_SURFACE)
vaDestroySurfaces (va_display, surfaces, surfaces_count);
}
return ret;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment