diff options
author | Younes Manton <younes.m@gmail.com> | 2008-09-17 22:00:37 -0400 |
---|---|---|
committer | Younes Manton <younes.m@gmail.com> | 2008-09-17 22:00:37 -0400 |
commit | 6fca18696d0e6a243f6fbb5a30de45100a8e5fa0 (patch) | |
tree | 213d3490590fedb2279ac8536b767c20ea2a4e2c /src/libXvMC/tests/testlib.c | |
parent | 3122f2bebe8d76568916b8cddff542f52466055e (diff) |
g3dvl: Update XvMC unit tests.
Diffstat (limited to 'src/libXvMC/tests/testlib.c')
-rw-r--r-- | src/libXvMC/tests/testlib.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/src/libXvMC/tests/testlib.c b/src/libXvMC/tests/testlib.c index 8672aa9999..59a03ca813 100644 --- a/src/libXvMC/tests/testlib.c +++ b/src/libXvMC/tests/testlib.c @@ -32,18 +32,18 @@ int GetPort int num_types; int ev_base, err_base; unsigned int i, j, k, l; - + if (!XvMCQueryExtension(display, &ev_base, &err_base)) return 0; if (XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info) != Success) return 0; - + for (i = 0; i < num_adaptors && !found_port; ++i) { if (adaptor_info[i].type & XvImageMask) { XvMCSurfaceInfo *surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types); - + if (surface_info) { for (j = 0; j < num_types && !found_port; ++j) @@ -74,14 +74,46 @@ int GetPort } } } - + XFree(surface_info); } } } - + XvFreeAdaptorInfo(adaptor_info); - + return found_port; } +unsigned int align(unsigned int value, unsigned int alignment) +{ + return (value + alignment - 1) & ~(alignment - 1); +} + +/* From the glibc manual */ +int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) +{ + /* Perform the carry for the later subtraction by updating y. */ + if (x->tv_usec < y->tv_usec) + { + int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; + y->tv_usec -= 1000000 * nsec; + y->tv_sec += nsec; + } + if (x->tv_usec - y->tv_usec > 1000000) + { + int nsec = (x->tv_usec - y->tv_usec) / 1000000; + y->tv_usec += 1000000 * nsec; + y->tv_sec -= nsec; + } + + /* + * Compute the time remaining to wait. + * tv_usec is certainly positive. + */ + result->tv_sec = x->tv_sec - y->tv_sec; + result->tv_usec = x->tv_usec - y->tv_usec; + + /* Return 1 if result is negative. */ + return x->tv_sec < y->tv_sec; +} |