hardware/intel/common/libva
Revision | f1f1f5a562693dccdae43e50909ca75556308486 (tree) |
---|---|
Time | 2017-09-27 13:48:16 |
Author | Mark Thompson <sw@jkqx...> |
Commiter | Xiang, Haihao |
Make logging callbacks library-safe
Move the logging callbacks into the display context, rather than
having them as global state. Add user-context parameter as well so
that users can distinguish between callbacks in different instances.
The default behaviour does not change, and LIBVA_MESSAGING_LEVEL
continues to be respected in that case.
Since we're breaking API here, also rename vaMessageCallback to
VAMessageCallback to be consistent with all other types.
Signed-off-by: Mark Thompson <sw@jkqxz.net>
@@ -52,9 +52,9 @@ | ||
52 | 52 | #define DRIVER_EXTENSION "_drv_video.so" |
53 | 53 | |
54 | 54 | #define ASSERT assert |
55 | -#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(ctx->vtable->va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; | |
56 | -#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; | |
57 | -#define CHECK_STRING(s, ctx, var) if (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; | |
55 | +#define CHECK_VTABLE(s, ctx, func) if (!va_checkVtable(dpy, ctx->vtable->va##func, #func)) s = VA_STATUS_ERROR_UNKNOWN; | |
56 | +#define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(dpy, ctx->max_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; | |
57 | +#define CHECK_STRING(s, ctx, var) if (!va_checkString(dpy, ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN; | |
58 | 58 | |
59 | 59 | /* |
60 | 60 | * read a config "env" for libva.conf or from environment setting |
@@ -114,8 +114,17 @@ int vaDisplayIsValid(VADisplay dpy) | ||
114 | 114 | return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext); |
115 | 115 | } |
116 | 116 | |
117 | -static void default_log_error(const char *buffer) | |
117 | +/* | |
118 | + * Global log level configured from the config file or environment, which sets | |
119 | + * whether default logging appears or not (always overridden by explicitly | |
120 | + * user-configured logging). | |
121 | + */ | |
122 | +static int default_log_level = 2; | |
123 | + | |
124 | +static void default_log_error(void *user_context, const char *buffer) | |
118 | 125 | { |
126 | + if (default_log_level < 1) | |
127 | + return; | |
119 | 128 | # ifdef ANDROID |
120 | 129 | ALOGE("%s", buffer); |
121 | 130 | # else |
@@ -123,8 +132,10 @@ static void default_log_error(const char *buffer) | ||
123 | 132 | # endif |
124 | 133 | } |
125 | 134 | |
126 | -static void default_log_info(const char *buffer) | |
135 | +static void default_log_info(void *user_context, const char *buffer) | |
127 | 136 | { |
137 | + if (default_log_level < 2) | |
138 | + return; | |
128 | 139 | # ifdef ANDROID |
129 | 140 | ALOGI("%s", buffer); |
130 | 141 | # else |
@@ -132,17 +143,24 @@ static void default_log_info(const char *buffer) | ||
132 | 143 | # endif |
133 | 144 | } |
134 | 145 | |
135 | -static vaMessageCallback va_log_error = default_log_error; | |
136 | -static vaMessageCallback va_log_info = default_log_info; | |
137 | - | |
138 | 146 | /** |
139 | 147 | * Set the callback for error messages, or NULL for no logging. |
140 | 148 | * Returns the previous one, or NULL if it was disabled. |
141 | 149 | */ |
142 | -vaMessageCallback vaSetErrorCallback(vaMessageCallback callback) | |
150 | +VAMessageCallback vaSetErrorCallback(VADisplay dpy, VAMessageCallback callback, void *user_context) | |
143 | 151 | { |
144 | - vaMessageCallback old_callback = va_log_error; | |
145 | - va_log_error = callback; | |
152 | + VADisplayContextP dctx; | |
153 | + VAMessageCallback old_callback; | |
154 | + | |
155 | + if (!vaDisplayIsValid(dpy)) | |
156 | + return NULL; | |
157 | + | |
158 | + dctx = (VADisplayContextP)dpy; | |
159 | + old_callback = dctx->error_callback; | |
160 | + | |
161 | + dctx->error_callback = callback; | |
162 | + dctx->error_callback_user_context = user_context; | |
163 | + | |
146 | 164 | return old_callback; |
147 | 165 | } |
148 | 166 |
@@ -150,39 +168,46 @@ vaMessageCallback vaSetErrorCallback(vaMessageCallback callback) | ||
150 | 168 | * Set the callback for info messages, or NULL for no logging. |
151 | 169 | * Returns the previous one, or NULL if it was disabled. |
152 | 170 | */ |
153 | -vaMessageCallback vaSetInfoCallback(vaMessageCallback callback) | |
171 | +VAMessageCallback vaSetInfoCallback(VADisplay dpy, VAMessageCallback callback, void *user_context) | |
154 | 172 | { |
155 | - vaMessageCallback old_callback = va_log_info; | |
156 | - va_log_info = callback; | |
173 | + VADisplayContextP dctx; | |
174 | + VAMessageCallback old_callback; | |
175 | + | |
176 | + if (!vaDisplayIsValid(dpy)) | |
177 | + return NULL; | |
178 | + | |
179 | + dctx = (VADisplayContextP)dpy; | |
180 | + old_callback = dctx->error_callback; | |
181 | + | |
182 | + dctx->info_callback = callback; | |
183 | + dctx->info_callback_user_context = user_context; | |
184 | + | |
157 | 185 | return old_callback; |
158 | 186 | } |
159 | 187 | |
160 | -void va_MessagingInit() | |
188 | +static void va_MessagingInit() | |
161 | 189 | { |
162 | 190 | #if ENABLE_VA_MESSAGING |
163 | 191 | char env_value[1024]; |
192 | + int ret; | |
164 | 193 | |
165 | 194 | if (va_parseConfig("LIBVA_MESSAGING_LEVEL", &env_value[0]) == 0) { |
166 | - if (strcmp(env_value, "0") == 0) { | |
167 | - vaSetInfoCallback(NULL); | |
168 | - vaSetErrorCallback(NULL); | |
169 | - } | |
170 | - | |
171 | - if (strcmp(env_value, "1") == 0) { | |
172 | - vaSetInfoCallback(NULL); | |
173 | - } | |
195 | + ret = sscanf(env_value, "%d", &default_log_level); | |
196 | + if (ret < 1 || default_log_level < 0 || default_log_level > 2) | |
197 | + default_log_level = 2; | |
174 | 198 | } |
175 | 199 | #endif |
176 | 200 | } |
177 | 201 | |
178 | -void va_errorMessage(const char *msg, ...) | |
202 | +void va_errorMessage(VADisplay dpy, const char *msg, ...) | |
179 | 203 | { |
180 | 204 | #if ENABLE_VA_MESSAGING |
205 | + VADisplayContextP dctx = (VADisplayContextP)dpy; | |
181 | 206 | char buf[512], *dynbuf; |
182 | 207 | va_list args; |
183 | 208 | int n, len; |
184 | 209 | |
185 | - if (va_log_error == NULL) | |
210 | + if (dctx->error_callback == NULL) | |
186 | 211 | return; |
187 | 212 | |
188 | 213 | va_start(args, msg); |
@@ -197,22 +222,23 @@ void va_errorMessage(const char *msg, ...) | ||
197 | 222 | n = vsnprintf(dynbuf, len + 1, msg, args); |
198 | 223 | va_end(args); |
199 | 224 | if (n == len) |
200 | - va_log_error(dynbuf); | |
225 | + dctx->error_callback(dctx->error_callback_user_context, dynbuf); | |
201 | 226 | free(dynbuf); |
202 | 227 | } |
203 | 228 | else if (len > 0) |
204 | - va_log_error(buf); | |
229 | + dctx->error_callback(dctx->error_callback_user_context, buf); | |
205 | 230 | #endif |
206 | 231 | } |
207 | 232 | |
208 | -void va_infoMessage(const char *msg, ...) | |
233 | +void va_infoMessage(VADisplay dpy, const char *msg, ...) | |
209 | 234 | { |
210 | 235 | #if ENABLE_VA_MESSAGING |
236 | + VADisplayContextP dctx = (VADisplayContextP)dpy; | |
211 | 237 | char buf[512], *dynbuf; |
212 | 238 | va_list args; |
213 | 239 | int n, len; |
214 | 240 | |
215 | - if (va_log_info == NULL) | |
241 | + if (dctx->info_callback == NULL) | |
216 | 242 | return; |
217 | 243 | |
218 | 244 | va_start(args, msg); |
@@ -227,11 +253,11 @@ void va_infoMessage(const char *msg, ...) | ||
227 | 253 | n = vsnprintf(dynbuf, len + 1, msg, args); |
228 | 254 | va_end(args); |
229 | 255 | if (n == len) |
230 | - va_log_info(dynbuf); | |
256 | + dctx->info_callback(dctx->info_callback_user_context, dynbuf); | |
231 | 257 | free(dynbuf); |
232 | 258 | } |
233 | 259 | else if (len > 0) |
234 | - va_log_info(buf); | |
260 | + dctx->info_callback(dctx->info_callback_user_context, buf); | |
235 | 261 | #endif |
236 | 262 | } |
237 | 263 |
@@ -243,31 +269,34 @@ VADisplayContextP va_newDisplayContext(void) | ||
243 | 269 | |
244 | 270 | dctx->vadpy_magic = VA_DISPLAY_MAGIC; |
245 | 271 | |
272 | + dctx->error_callback = default_log_error; | |
273 | + dctx->info_callback = default_log_info; | |
274 | + | |
246 | 275 | return dctx; |
247 | 276 | } |
248 | 277 | |
249 | -static bool va_checkVtable(void *ptr, char *function) | |
278 | +static bool va_checkVtable(VADisplay dpy, void *ptr, char *function) | |
250 | 279 | { |
251 | 280 | if (!ptr) { |
252 | - va_errorMessage("No valid vtable entry for va%s\n", function); | |
281 | + va_errorMessage(dpy, "No valid vtable entry for va%s\n", function); | |
253 | 282 | return false; |
254 | 283 | } |
255 | 284 | return true; |
256 | 285 | } |
257 | 286 | |
258 | -static bool va_checkMaximum(int value, char *variable) | |
287 | +static bool va_checkMaximum(VADisplay dpy, int value, char *variable) | |
259 | 288 | { |
260 | 289 | if (!value) { |
261 | - va_errorMessage("Failed to define max_%s in init\n", variable); | |
290 | + va_errorMessage(dpy, "Failed to define max_%s in init\n", variable); | |
262 | 291 | return false; |
263 | 292 | } |
264 | 293 | return true; |
265 | 294 | } |
266 | 295 | |
267 | -static bool va_checkString(const char* value, char *variable) | |
296 | +static bool va_checkString(VADisplay dpy, const char* value, char *variable) | |
268 | 297 | { |
269 | 298 | if (!value) { |
270 | - va_errorMessage("Failed to define str_%s in init\n", variable); | |
299 | + va_errorMessage(dpy, "Failed to define str_%s in init\n", variable); | |
271 | 300 | return false; |
272 | 301 | } |
273 | 302 | return true; |
@@ -309,9 +338,9 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
309 | 338 | strlen(driver_name) + |
310 | 339 | strlen(DRIVER_EXTENSION) + 2 ); |
311 | 340 | if (!driver_path) { |
312 | - va_errorMessage("%s L%d Out of memory!n", | |
313 | - __FUNCTION__, __LINE__); | |
314 | - free(search_path); | |
341 | + va_errorMessage(dpy, "%s L%d Out of memory!n", | |
342 | + __FUNCTION__, __LINE__); | |
343 | + free(search_path); | |
315 | 344 | return VA_STATUS_ERROR_ALLOCATION_FAILED; |
316 | 345 | } |
317 | 346 |
@@ -320,7 +349,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
320 | 349 | strncat( driver_path, driver_name, strlen(driver_name) ); |
321 | 350 | strncat( driver_path, DRIVER_EXTENSION, strlen(DRIVER_EXTENSION) ); |
322 | 351 | |
323 | - va_infoMessage("Trying to open %s\n", driver_path); | |
352 | + va_infoMessage(dpy, "Trying to open %s\n", driver_path); | |
324 | 353 | #ifndef ANDROID |
325 | 354 | handle = dlopen( driver_path, RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE ); |
326 | 355 | #else |
@@ -329,7 +358,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
329 | 358 | if (!handle) { |
330 | 359 | /* Don't give errors for non-existing files */ |
331 | 360 | if (0 == access( driver_path, F_OK)) |
332 | - va_errorMessage("dlopen of %s failed: %s\n", driver_path, dlerror()); | |
361 | + va_errorMessage(dpy, "dlopen of %s failed: %s\n", driver_path, dlerror()); | |
333 | 362 | } else { |
334 | 363 | VADriverInit init_func = NULL; |
335 | 364 | char init_func_s[256]; |
@@ -349,14 +378,14 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
349 | 378 | compatible_versions[i].minor)) { |
350 | 379 | init_func = (VADriverInit)dlsym(handle, init_func_s); |
351 | 380 | if (init_func) { |
352 | - va_infoMessage("Found init function %s\n", init_func_s); | |
381 | + va_infoMessage(dpy, "Found init function %s\n", init_func_s); | |
353 | 382 | break; |
354 | 383 | } |
355 | 384 | } |
356 | 385 | } |
357 | 386 | |
358 | 387 | if (compatible_versions[i].major < 0) { |
359 | - va_errorMessage("%s has no function %s\n", | |
388 | + va_errorMessage(dpy, "%s has no function %s\n", | |
360 | 389 | driver_path, init_func_s); |
361 | 390 | dlclose(handle); |
362 | 391 | } else { |
@@ -433,7 +462,7 @@ static VAStatus va_openDriver(VADisplay dpy, char *driver_name) | ||
433 | 462 | CHECK_VTABLE(vaStatus, ctx, SetDisplayAttributes); |
434 | 463 | } |
435 | 464 | if (VA_STATUS_SUCCESS != vaStatus) { |
436 | - va_errorMessage("%s init failed\n", driver_path); | |
465 | + va_errorMessage(dpy, "%s init failed\n", driver_path); | |
437 | 466 | dlclose(handle); |
438 | 467 | } |
439 | 468 | if (VA_STATUS_SUCCESS == vaStatus) |
@@ -550,13 +579,13 @@ VAStatus vaSetDriverName( | ||
550 | 579 | |
551 | 580 | if (geteuid() != getuid()) { |
552 | 581 | vaStatus = VA_STATUS_ERROR_OPERATION_FAILED; |
553 | - va_errorMessage("no permission to vaSetDriverName\n"); | |
582 | + va_errorMessage(dpy, "no permission to vaSetDriverName\n"); | |
554 | 583 | return vaStatus; |
555 | 584 | } |
556 | 585 | |
557 | 586 | if (strlen(driver_name) == 0 || strlen(driver_name) >=256) { |
558 | 587 | vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; |
559 | - va_errorMessage("vaSetDriverName returns %s\n", | |
588 | + va_errorMessage(dpy, "vaSetDriverName returns %s\n", | |
560 | 589 | vaErrorStr(vaStatus)); |
561 | 590 | return vaStatus; |
562 | 591 | } |
@@ -573,7 +602,7 @@ VAStatus vaSetDriverName( | ||
573 | 602 | |
574 | 603 | if (!found) { |
575 | 604 | vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER; |
576 | - va_errorMessage("vaSetDriverName returns %s. Incorrect parameter\n", | |
605 | + va_errorMessage(dpy, "vaSetDriverName returns %s. Incorrect parameter\n", | |
577 | 606 | vaErrorStr(vaStatus)); |
578 | 607 | return vaStatus; |
579 | 608 | } |
@@ -582,7 +611,7 @@ VAStatus vaSetDriverName( | ||
582 | 611 | |
583 | 612 | if (!override_driver_name) { |
584 | 613 | vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; |
585 | - va_errorMessage("vaSetDriverName returns %s. Out of Memory\n", | |
614 | + va_errorMessage(dpy, "vaSetDriverName returns %s. Out of Memory\n", | |
586 | 615 | vaErrorStr(vaStatus)); |
587 | 616 | return vaStatus; |
588 | 617 | } |
@@ -612,12 +641,12 @@ VAStatus vaInitialize ( | ||
612 | 641 | |
613 | 642 | va_MessagingInit(); |
614 | 643 | |
615 | - va_infoMessage("VA-API version %s\n", VA_VERSION_S); | |
644 | + va_infoMessage(dpy, "VA-API version %s\n", VA_VERSION_S); | |
616 | 645 | |
617 | 646 | vaStatus = va_getDriverName(dpy, &driver_name); |
618 | 647 | |
619 | 648 | if (!ctx->override_driver_name) { |
620 | - va_infoMessage("va_getDriverName() returns %d\n", vaStatus); | |
649 | + va_infoMessage(dpy, "va_getDriverName() returns %d\n", vaStatus); | |
621 | 650 | |
622 | 651 | driver_name_env = getenv("LIBVA_DRIVER_NAME"); |
623 | 652 | } else if (vaStatus == VA_STATUS_SUCCESS) { |
@@ -627,11 +656,11 @@ VAStatus vaInitialize ( | ||
627 | 656 | driver_name = strdup(ctx->override_driver_name); |
628 | 657 | if (!driver_name) { |
629 | 658 | vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED; |
630 | - va_errorMessage("vaInitialize() failed with %s, out of memory\n", | |
659 | + va_errorMessage(dpy, "vaInitialize() failed with %s, out of memory\n", | |
631 | 660 | vaErrorStr(vaStatus)); |
632 | 661 | return vaStatus; |
633 | 662 | } |
634 | - va_infoMessage("User requested driver '%s'\n", driver_name); | |
663 | + va_infoMessage(dpy, "User requested driver '%s'\n", driver_name); | |
635 | 664 | } |
636 | 665 | |
637 | 666 | if (driver_name_env && (geteuid() == getuid())) { |
@@ -641,17 +670,17 @@ VAStatus vaInitialize ( | ||
641 | 670 | |
642 | 671 | driver_name = strdup(driver_name_env); |
643 | 672 | vaStatus = VA_STATUS_SUCCESS; |
644 | - va_infoMessage("User requested driver '%s'\n", driver_name); | |
673 | + va_infoMessage(dpy, "User requested driver '%s'\n", driver_name); | |
645 | 674 | } |
646 | 675 | |
647 | 676 | if ((VA_STATUS_SUCCESS == vaStatus) && (driver_name != NULL)) { |
648 | 677 | vaStatus = va_openDriver(dpy, driver_name); |
649 | - va_infoMessage("va_openDriver() returns %d\n", vaStatus); | |
678 | + va_infoMessage(dpy, "va_openDriver() returns %d\n", vaStatus); | |
650 | 679 | |
651 | 680 | *major_version = VA_MAJOR_VERSION; |
652 | 681 | *minor_version = VA_MINOR_VERSION; |
653 | 682 | } else |
654 | - va_errorMessage("va_getDriverName() failed with %s,driver_name=%s\n", | |
683 | + va_errorMessage(dpy, "va_getDriverName() failed with %s,driver_name=%s\n", | |
655 | 684 | vaErrorStr(vaStatus), driver_name); |
656 | 685 | |
657 | 686 | if (driver_name) |
@@ -241,19 +241,19 @@ typedef struct _VAMotionVector { | ||
241 | 241 | } VAMotionVector; |
242 | 242 | |
243 | 243 | /** Type of a message callback, used for both error and info log. */ |
244 | -typedef void (*vaMessageCallback)(const char *message); | |
244 | +typedef void (*VAMessageCallback)(void *user_context, const char *message); | |
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Set the callback for error messages, or NULL for no logging. |
248 | 248 | * Returns the previous one, or NULL if it was disabled. |
249 | 249 | */ |
250 | -vaMessageCallback vaSetErrorCallback(vaMessageCallback); | |
250 | +VAMessageCallback vaSetErrorCallback(VADisplay dpy, VAMessageCallback callback, void *user_context); | |
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Set the callback for info messages, or NULL for no logging. |
254 | 254 | * Returns the previous one, or NULL if it was disabled. |
255 | 255 | */ |
256 | -vaMessageCallback vaSetInfoCallback(vaMessageCallback); | |
256 | +VAMessageCallback vaSetInfoCallback(VADisplay dpy, VAMessageCallback callback, void *user_context); | |
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Initialization: |
@@ -553,6 +553,11 @@ struct VADisplayContext | ||
553 | 553 | void *opaque; /* opaque for display extensions (e.g. GLX) */ |
554 | 554 | void *vatrace; /* opaque for VA trace context */ |
555 | 555 | void *vafool; /* opaque for VA fool context */ |
556 | + | |
557 | + VAMessageCallback error_callback; | |
558 | + void *error_callback_user_context; | |
559 | + VAMessageCallback info_callback; | |
560 | + void *info_callback_user_context; | |
556 | 561 | }; |
557 | 562 | |
558 | 563 | typedef VAStatus (*VADriverInit) ( |
@@ -115,23 +115,23 @@ void va_FoolInit(VADisplay dpy) | ||
115 | 115 | |
116 | 116 | if (va_parseConfig("LIBVA_FOOL_POSTP", NULL) == 0) { |
117 | 117 | fool_postp = 1; |
118 | - va_infoMessage("LIBVA_FOOL_POSTP is on, dummy vaPutSurface\n"); | |
118 | + va_infoMessage(dpy, "LIBVA_FOOL_POSTP is on, dummy vaPutSurface\n"); | |
119 | 119 | } |
120 | 120 | |
121 | 121 | if (va_parseConfig("LIBVA_FOOL_DECODE", NULL) == 0) { |
122 | 122 | fool_codec |= VA_FOOL_FLAG_DECODE; |
123 | - va_infoMessage("LIBVA_FOOL_DECODE is on, dummy decode\n"); | |
123 | + va_infoMessage(dpy, "LIBVA_FOOL_DECODE is on, dummy decode\n"); | |
124 | 124 | } |
125 | 125 | if (va_parseConfig("LIBVA_FOOL_ENCODE", &env_value[0]) == 0) { |
126 | 126 | fool_codec |= VA_FOOL_FLAG_ENCODE; |
127 | 127 | fool_ctx->fn_enc = strdup(env_value); |
128 | - va_infoMessage("LIBVA_FOOL_ENCODE is on, load encode data from file with patten %s\n", | |
128 | + va_infoMessage(dpy, "LIBVA_FOOL_ENCODE is on, load encode data from file with patten %s\n", | |
129 | 129 | fool_ctx->fn_enc); |
130 | 130 | } |
131 | 131 | if (va_parseConfig("LIBVA_FOOL_JPEG", &env_value[0]) == 0) { |
132 | 132 | fool_codec |= VA_FOOL_FLAG_JPEG; |
133 | 133 | fool_ctx->fn_jpg = strdup(env_value); |
134 | - va_infoMessage("LIBVA_FOOL_JPEG is on, load encode data from file with patten %s\n", | |
134 | + va_infoMessage(dpy, "LIBVA_FOOL_JPEG is on, load encode data from file with patten %s\n", | |
135 | 135 | fool_ctx->fn_jpg); |
136 | 136 | } |
137 | 137 |
@@ -200,9 +200,9 @@ int va_FoolCreateConfig( | ||
200 | 200 | fool_ctx->enabled = 1; |
201 | 201 | } |
202 | 202 | if (fool_ctx->enabled) |
203 | - va_infoMessage("FOOL is enabled for this context\n"); | |
203 | + va_infoMessage(dpy, "FOOL is enabled for this context\n"); | |
204 | 204 | else |
205 | - va_infoMessage("FOOL is not enabled for this context\n"); | |
205 | + va_infoMessage(dpy, "FOOL is not enabled for this context\n"); | |
206 | 206 | |
207 | 207 | |
208 | 208 | return 0; /* continue */ |
@@ -28,8 +28,8 @@ | ||
28 | 28 | #define CTX(dpy) (((VADisplayContextP)dpy)->pDriverContext) |
29 | 29 | #define CHECK_DISPLAY(dpy) if( !vaDisplayIsValid(dpy) ) { return VA_STATUS_ERROR_INVALID_DISPLAY; } |
30 | 30 | |
31 | -void va_errorMessage(const char *msg, ...); | |
32 | -void va_infoMessage(const char *msg, ...); | |
31 | +void va_errorMessage(VADisplay dpy, const char *msg, ...); | |
32 | +void va_infoMessage(VADisplay dpy, const char *msg, ...); | |
33 | 33 | |
34 | 34 | int va_parseConfig(char *env, char *env_value); |
35 | 35 |
@@ -162,6 +162,7 @@ struct va_trace { | ||
162 | 162 | |
163 | 163 | pthread_mutex_t resource_mutex; |
164 | 164 | pthread_mutex_t context_mutex; |
165 | + VADisplay dpy; | |
165 | 166 | }; |
166 | 167 | |
167 | 168 | #define LOCK_RESOURCE(pva_trace) \ |
@@ -392,7 +393,7 @@ static void add_trace_buf_info( | ||
392 | 393 | } |
393 | 394 | |
394 | 395 | if(i >= MAX_TRACE_BUF_INFO_HASH_LEVEL) |
395 | - va_errorMessage("Add buf info failed\n"); | |
396 | + va_errorMessage(pva_trace->dpy, "Add buf info failed\n"); | |
396 | 397 | |
397 | 398 | UNLOCK_RESOURCE(pva_trace); |
398 | 399 | } |
@@ -581,7 +582,7 @@ static int open_tracing_log_file( | ||
581 | 582 | int new_fn_flag = 0; |
582 | 583 | |
583 | 584 | if(plog_file->used && plog_file->thread_id != thd_id) { |
584 | - va_errorMessage("Try to open a busy log file occupied by other thread\n"); | |
585 | + va_errorMessage(pva_trace->dpy, "Try to open a busy log file occupied by other thread\n"); | |
585 | 586 | |
586 | 587 | return -1; |
587 | 588 | } |
@@ -757,7 +758,7 @@ void va_TraceInit(VADisplay dpy) | ||
757 | 758 | if ((trace_flag & VA_TRACE_FLAG_LOG) && (va_parseConfig("LIBVA_TRACE_BUFDATA", NULL) == 0)) { |
758 | 759 | trace_flag |= VA_TRACE_FLAG_BUFDATA; |
759 | 760 | |
760 | - va_infoMessage("LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n"); | |
761 | + va_infoMessage(dpy, "LIBVA_TRACE_BUFDATA is on, dump buffer into log file\n"); | |
761 | 762 | } |
762 | 763 | |
763 | 764 | /* per-context setting */ |
@@ -793,7 +794,7 @@ void va_TraceInit(VADisplay dpy) | ||
793 | 794 | p = q+1; /* skip "+" */ |
794 | 795 | trace_ctx->trace_surface_yoff = strtod(p, &q); |
795 | 796 | |
796 | - va_infoMessage("LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n", | |
797 | + va_infoMessage(dpy, "LIBVA_TRACE_SURFACE_GEOMETRY is on, only dump surface %dx%d+%d+%d content\n", | |
797 | 798 | trace_ctx->trace_surface_width, |
798 | 799 | trace_ctx->trace_surface_height, |
799 | 800 | trace_ctx->trace_surface_xoff, |
@@ -808,6 +809,7 @@ void va_TraceInit(VADisplay dpy) | ||
808 | 809 | pva_trace->ptra_ctx[MAX_TRACE_CTX_NUM] = trace_ctx; |
809 | 810 | |
810 | 811 | ((VADisplayContextP)dpy)->vatrace = (void *)pva_trace; |
812 | + pva_trace->dpy = dpy; | |
811 | 813 | |
812 | 814 | if(!trace_flag) |
813 | 815 | va_TraceEnd(dpy); |
@@ -1291,7 +1293,7 @@ void va_TraceCreateContext( | ||
1291 | 1293 | if(!context |
1292 | 1294 | || *context == VA_INVALID_ID |
1293 | 1295 | || !pva_trace) { |
1294 | - va_errorMessage("Invalid context id 0x%08x\n", | |
1296 | + va_errorMessage(dpy, "Invalid context id 0x%08x\n", | |
1295 | 1297 | context == NULL ? 0 : (int)*context); |
1296 | 1298 | return; |
1297 | 1299 | } |
@@ -1300,7 +1302,7 @@ void va_TraceCreateContext( | ||
1300 | 1302 | |
1301 | 1303 | tra_ctx_id = get_free_ctx_idx(pva_trace, *context); |
1302 | 1304 | if(tra_ctx_id >= MAX_TRACE_CTX_NUM) { |
1303 | - va_errorMessage("Can't get trace context for ctx 0x%08x\n", | |
1305 | + va_errorMessage(dpy, "Can't get trace context for ctx 0x%08x\n", | |
1304 | 1306 | *context); |
1305 | 1307 | |
1306 | 1308 | goto FAIL; |
@@ -1308,7 +1310,7 @@ void va_TraceCreateContext( | ||
1308 | 1310 | |
1309 | 1311 | trace_ctx = calloc(sizeof(struct trace_context), 1); |
1310 | 1312 | if(trace_ctx == NULL) { |
1311 | - va_errorMessage("Allocate trace context failed for ctx 0x%08x\n", | |
1313 | + va_errorMessage(dpy, "Allocate trace context failed for ctx 0x%08x\n", | |
1312 | 1314 | *context); |
1313 | 1315 | |
1314 | 1316 | goto FAIL; |
@@ -1316,7 +1318,7 @@ void va_TraceCreateContext( | ||
1316 | 1318 | |
1317 | 1319 | i = get_valid_config_idx(pva_trace, config_id); |
1318 | 1320 | if(i >= MAX_TRACE_CTX_NUM) { |
1319 | - va_errorMessage("Can't get trace config id for ctx 0x%08x cfg %x\n", | |
1321 | + va_errorMessage(dpy, "Can't get trace config id for ctx 0x%08x cfg %x\n", | |
1320 | 1322 | *context, config_id); |
1321 | 1323 | |
1322 | 1324 | goto FAIL; |
@@ -1327,13 +1329,13 @@ void va_TraceCreateContext( | ||
1327 | 1329 | if(trace_flag & VA_TRACE_FLAG_LOG) { |
1328 | 1330 | trace_ctx->plog_file = start_tracing2log_file(pva_trace); |
1329 | 1331 | if(!trace_ctx->plog_file) { |
1330 | - va_errorMessage("Can't get trace log file for ctx 0x%08x\n", | |
1332 | + va_errorMessage(dpy, "Can't get trace log file for ctx 0x%08x\n", | |
1331 | 1333 | *context); |
1332 | 1334 | |
1333 | 1335 | goto FAIL; |
1334 | 1336 | } |
1335 | 1337 | else |
1336 | - va_infoMessage("Save context 0x%08x into log file %s\n", *context, | |
1338 | + va_infoMessage(dpy, "Save context 0x%08x into log file %s\n", *context, | |
1337 | 1339 | trace_ctx->plog_file->fn_log); |
1338 | 1340 | |
1339 | 1341 | trace_ctx->plog_file_list[0] = trace_ctx->plog_file; |
@@ -1373,7 +1375,7 @@ void va_TraceCreateContext( | ||
1373 | 1375 | (decode && (trace_flag & VA_TRACE_FLAG_SURFACE_DECODE)) || |
1374 | 1376 | (jpeg && (trace_flag & VA_TRACE_FLAG_SURFACE_JPEG))) { |
1375 | 1377 | if(open_tracing_specil_file(pva_trace, trace_ctx, 1) < 0) { |
1376 | - va_errorMessage("Open surface fail failed for ctx 0x%08x\n", *context); | |
1378 | + va_errorMessage(dpy, "Open surface fail failed for ctx 0x%08x\n", *context); | |
1377 | 1379 | |
1378 | 1380 | trace_flag &= ~(VA_TRACE_FLAG_SURFACE); |
1379 | 1381 | } |
@@ -1381,7 +1383,7 @@ void va_TraceCreateContext( | ||
1381 | 1383 | |
1382 | 1384 | if (encode && (trace_flag & VA_TRACE_FLAG_CODEDBUF)) { |
1383 | 1385 | if(open_tracing_specil_file(pva_trace, trace_ctx, 0) < 0) { |
1384 | - va_errorMessage("Open codedbuf fail failed for ctx 0x%08x\n", *context); | |
1386 | + va_errorMessage(dpy, "Open codedbuf fail failed for ctx 0x%08x\n", *context); | |
1385 | 1387 | |
1386 | 1388 | trace_flag &= ~(VA_TRACE_FLAG_CODEDBUF); |
1387 | 1389 | } |