• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

hardware/intel/common/libva


Commit MetaInfo

Révision9c512edec4e4010a14981b497adb9f86b4a368ed (tree)
l'heure2017-11-22 14:38:52
AuteurMark Thompson <sw@jkqx...>
CommiterXiang, Haihao

Message de Log

Add message callbacks for drivers to use

This adds a mechanism for drivers to propagate arbitrary log messages
back to the API user. It is intended to be used to replace all use of
logging to stdout/stderr in drivers.

Signed-off-by: Mark Thompson <sw@jkqxz.net>

Change Summary

Modification

--- a/va/va.c
+++ b/va/va.c
@@ -261,6 +261,24 @@ void va_infoMessage(VADisplay dpy, const char *msg, ...)
261261 #endif
262262 }
263263
264+static void va_driverErrorCallback(VADriverContextP ctx,
265+ const char *message)
266+{
267+ VADisplayContextP dctx = ctx->pDisplayContext;
268+ if (!dctx)
269+ return;
270+ dctx->error_callback(dctx->error_callback_user_context, message);
271+}
272+
273+static void va_driverInfoCallback(VADriverContextP ctx,
274+ const char *message)
275+{
276+ VADisplayContextP dctx = ctx->pDisplayContext;
277+ if (!dctx)
278+ return;
279+ dctx->info_callback(dctx->info_callback_user_context, message);
280+}
281+
264282 VADisplayContextP va_newDisplayContext(void)
265283 {
266284 VADisplayContextP dctx = calloc(1, sizeof(*dctx));
@@ -282,6 +300,10 @@ VADriverContextP va_newDriverContext(VADisplayContextP dctx)
282300 return NULL;
283301
284302 dctx->pDriverContext = ctx;
303+ ctx->pDisplayContext = dctx;
304+
305+ ctx->error_callback = va_driverErrorCallback;
306+ ctx->info_callback = va_driverInfoCallback;
285307
286308 return ctx;
287309 }
--- a/va/va_backend.h
+++ b/va/va_backend.h
@@ -552,7 +552,48 @@ struct VADriverContext
552552
553553 char *override_driver_name;
554554
555- unsigned long reserved[41]; /* reserve for future add-ins, decrease the subscript accordingly */
555+ void *pDisplayContext;
556+
557+ /**
558+ * Error callback.
559+ *
560+ * This is set by libva when the driver is opened, and will not be
561+ * changed thereafter. The driver can call it with an error message,
562+ * which will be propagated to the API user through their error
563+ * callbacks, or sent to a default output if no callback is available.
564+ *
565+ * It is expected that end users will always be able to see these
566+ * messages, so it should be called only for serious errors. For
567+ * example, hardware problems or fatal configuration errors.
568+ *
569+ * @param pDriverContext Pointer to the driver context structure
570+ * being used by the current driver.
571+ * @param message Message to send to the API user. This must be a
572+ * null-terminated string.
573+ */
574+ void (*error_callback)(VADriverContextP pDriverContext,
575+ const char *message);
576+ /**
577+ * Info callback.
578+ *
579+ * This has the same behaviour as the error callback, but has its
580+ * own set of callbacks to the API user.
581+ *
582+ * It should be used for informational messages which may be useful
583+ * for an application programmer or for debugging. For example, minor
584+ * configuration errors, or information about the reason when another
585+ * API call generates an error return. It is not expected that end
586+ * users will see these messages.
587+ *
588+ * @param pDriverContext Pointer to the driver context structure
589+ * being used by the current driver.
590+ * @param message Message to send to the API user. This must be a
591+ * null-terminated string.
592+ */
593+ void (*info_callback)(VADriverContextP pDriverContext,
594+ const char *message);
595+
596+ unsigned long reserved[38]; /* reserve for future add-ins, decrease the subscript accordingly */
556597 };
557598
558599 #define VA_DISPLAY_MAGIC 0x56414430 /* VAD0 */