[Libva] [PATCH libva 1/2] trace: Add `va_TracePrint`, `va_TraceVPrint` static functions

Scott D Phillips scott.d.phillips at intel.com
Tue May 17 22:29:07 UTC 2016


These functions are similar to va_TraceMsg() but without emitting
a timestamp.

Signed-off-by: Scott D Phillips <scott.d.phillips at intel.com>
---
 va/va_trace.c | 50 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 16 deletions(-)

diff --git a/va/va_trace.c b/va/va_trace.c
index f632176..5c345f2 100644
--- a/va/va_trace.c
+++ b/va/va_trace.c
@@ -877,10 +877,9 @@ void va_TraceEnd(VADisplay dpy)
     ((VADisplayContextP)dpy)->vatrace = NULL;
 }
 
-static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
+static void va_TraceVPrint(struct trace_context *trace_ctx, const char *msg, va_list args)
 {
     FILE *fp = NULL;
-    va_list args;
 
     if (!(trace_flag & VA_TRACE_FLAG_LOG)
         || !trace_ctx->plog_file)
@@ -888,25 +887,44 @@ static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
 
     fp = trace_ctx->plog_file->fp_log;
     if (msg)  {
-        struct timeval tv;
-
-        if (gettimeofday(&tv, NULL) == 0)
-            fprintf(fp, "[%04d.%06d]",
-                (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec);
-
-        if(trace_ctx->trace_context != VA_INVALID_ID)
-            fprintf(fp,
-                "[ctx 0x%08x]", trace_ctx->trace_context);
-        else
-            fprintf(fp, "[ctx       none]");
-
-        va_start(args, msg);
         vfprintf(fp, msg, args);
-        va_end(args);
     } else
         fflush(fp);
 }
 
+static void va_TracePrint(struct trace_context *trace_ctx, const char *msg, ...)
+{
+    va_list args;
+    va_start(args, msg);
+    va_TraceVPrint(trace_ctx, msg, args);
+    va_end(args);
+}
+
+static void va_TraceMsg(struct trace_context *trace_ctx, const char *msg, ...)
+{
+    va_list args;
+    struct timeval tv;
+
+    if (!msg) {
+        va_TracePrint(trace_ctx, msg);
+        return;
+    }
+
+    if (gettimeofday(&tv, NULL) == 0)
+        va_TracePrint(trace_ctx, "[%04d.%06d]",
+            (unsigned int)tv.tv_sec & 0xffff, (unsigned int)tv.tv_usec);
+
+    if(trace_ctx->trace_context != VA_INVALID_ID)
+        va_TracePrint(trace_ctx,
+            "[ctx 0x%08x]", trace_ctx->trace_context);
+    else
+        va_TracePrint(trace_ctx, "[ctx       none]");
+
+    va_start(args, msg);
+    va_TraceVPrint(trace_ctx, msg, args);
+    va_end(args);
+}
+
 static void va_TraceSurface(VADisplay dpy, VAContextID context)
 {
     unsigned int i, j;
-- 
2.7.4



More information about the Libva mailing list