[vlc-commits] [Git][videolan/vlc][master] 2 commits: vlc_tracer: align arguments to improve readability

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Jun 2 01:53:48 UTC 2023



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
bbc7b76e by Romain Vimont at 2023-06-02T01:29:51+00:00
vlc_tracer: align arguments to improve readability

- - - - -
cf148903 by Romain Vimont at 2023-06-02T01:29:51+00:00
vlc_tracer: remove TICK type

Pass the nanoseconds value as an integer instead.

Refs !3742

- - - - -


5 changed files:

- include/vlc_tracer.h
- modules/logger/json.c
- src/audio_output/dec.c
- src/clock/clock.c
- src/video_output/video_output.c


Changes:

=====================================
include/vlc_tracer.h
=====================================
@@ -46,14 +46,12 @@
 enum vlc_tracer_value
 {
     VLC_TRACER_INT,
-    VLC_TRACER_TICK,
     VLC_TRACER_STRING
 };
 
 typedef union
 {
     int64_t integer;
-    vlc_tick_t tick;
     const char *string;
 } vlc_tracer_value_t;
 
@@ -106,11 +104,11 @@ VLC_API void vlc_tracer_TraceWithTs(struct vlc_tracer *tracer, vlc_tick_t ts, ..
  * @{
  */
 
-static inline struct vlc_tracer_entry vlc_tracer_entry_FromTick(const char *key, vlc_tick_t value)
+static inline struct vlc_tracer_entry vlc_tracer_entry_FromInt(const char *key, int64_t value)
 {
     vlc_tracer_value_t tracer_value;
-    tracer_value.tick = value;
-    struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_TICK };
+    tracer_value.integer = value;
+    struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_INT };
     return trace;
 }
 
@@ -128,16 +126,16 @@ static inline struct vlc_tracer_entry vlc_tracer_entry_FromString(const char *ke
 
 #define VLC_TRACE(key, value) \
         _Generic((value), \
-        vlc_tick_t: vlc_tracer_entry_FromTick, \
+        int64_t: vlc_tracer_entry_FromInt, \
         char *: vlc_tracer_entry_FromString, \
         const char *: vlc_tracer_entry_FromString) (key, value)
 #else
 #define VLC_TRACE_END \
         vlc_tracer_entry_FromString(nullptr, nullptr)
 
-static inline struct vlc_tracer_entry VLC_TRACE(const char *key, vlc_tick_t value)
+static inline struct vlc_tracer_entry VLC_TRACE(const char *key, int64_t value)
 {
-    return vlc_tracer_entry_FromTick(key, value);
+    return vlc_tracer_entry_FromInt(key, value);
 }
 
 static inline struct vlc_tracer_entry VLC_TRACE(const char *key, char *value)
@@ -151,6 +149,8 @@ static inline struct vlc_tracer_entry VLC_TRACE(const char *key, const char *val
 }
 #endif
 
+#define VLC_TRACE_TICK_NS(key, tick) VLC_TRACE((key), NS_FROM_VLC_TICK((tick)))
+
 /*
  * Helper trace functions
  */
@@ -159,18 +159,23 @@ static inline void vlc_tracer_TraceStreamPTS(struct vlc_tracer *tracer, const ch
                                 const char *id, const char* stream,
                                 vlc_tick_t pts)
 {
-    vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
-                     VLC_TRACE("stream", stream), VLC_TRACE("pts", pts),
-                     VLC_TRACE_END);
+    vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
+                             VLC_TRACE("id", id),
+                             VLC_TRACE("stream", stream),
+                             VLC_TRACE_TICK_NS("pts", pts),
+                             VLC_TRACE_END);
 }
 
 static inline void vlc_tracer_TraceStreamDTS(struct vlc_tracer *tracer, const char *type,
                                 const char *id, const char* stream,
                                 vlc_tick_t pts, vlc_tick_t dts)
 {
-    vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
-                     VLC_TRACE("stream", stream), VLC_TRACE("pts", pts),
-                     VLC_TRACE("dts", dts), VLC_TRACE_END);
+    vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
+                             VLC_TRACE("id", id),
+                             VLC_TRACE("stream", stream),
+                             VLC_TRACE_TICK_NS("pts", pts),
+                             VLC_TRACE_TICK_NS("dts", dts),
+                             VLC_TRACE_END);
 }
 
 static inline void vlc_tracer_TraceRender(struct vlc_tracer *tracer, const char *type,
@@ -178,31 +183,42 @@ static inline void vlc_tracer_TraceRender(struct vlc_tracer *tracer, const char
 {
     if (now != VLC_TICK_MAX && now != VLC_TICK_INVALID)
     {
-        vlc_tracer_TraceWithTs(tracer, vlc_tick_now(), VLC_TRACE("type", type),
-                               VLC_TRACE("id", id), VLC_TRACE("pts", pts),
-                               VLC_TRACE("render_ts", now), VLC_TRACE_END);
-        vlc_tracer_TraceWithTs(tracer, now, VLC_TRACE("type", type),
-                               VLC_TRACE("id", id), VLC_TRACE("render_pts", pts),
+        vlc_tracer_TraceWithTs(tracer, vlc_tick_now(),
+                               VLC_TRACE("type", type),
+                               VLC_TRACE("id", id),
+                               VLC_TRACE_TICK_NS("pts", pts),
+                               VLC_TRACE_TICK_NS("render_ts", now),
+                               VLC_TRACE_END);
+        vlc_tracer_TraceWithTs(tracer, now,
+                               VLC_TRACE("type", type),
+                               VLC_TRACE("id", id),
+                               VLC_TRACE_TICK_NS("render_pts", pts),
                                VLC_TRACE_END);
 
     }
     else
-        vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
-                         VLC_TRACE("pts", pts), VLC_TRACE_END);
+        vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
+                                 VLC_TRACE("id", id),
+                                 VLC_TRACE_TICK_NS("pts", pts),
+                                 VLC_TRACE_END);
 }
 
 static inline void vlc_tracer_TraceEvent(struct vlc_tracer *tracer, const char *type,
                                          const char *id, const char *event)
 {
-    vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
-                     VLC_TRACE("event", event), VLC_TRACE_END);
+    vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
+                             VLC_TRACE("id", id),
+                             VLC_TRACE("event", event),
+                             VLC_TRACE_END);
 }
 
 static inline void vlc_tracer_TracePCR( struct vlc_tracer *tracer, const char *type,
                                     const char *id, vlc_tick_t pcr)
 {
-    vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
-                     VLC_TRACE("pcr", pcr), VLC_TRACE_END);
+    vlc_tracer_Trace(tracer, VLC_TRACE("type", type),
+                             VLC_TRACE("id", id),
+                             VLC_TRACE_TICK_NS("pcr", pcr),
+                             VLC_TRACE_END);
 }
 
 /**


=====================================
modules/logger/json.c
=====================================
@@ -178,10 +178,6 @@ static void TraceJson(void *opaque, vlc_tick_t ts, va_list entries)
             case VLC_TRACER_INT:
                 JsonPrintKeyValueNumber(stream, entry.key, entry.value.integer);
                 break;
-            case VLC_TRACER_TICK:
-                JsonPrintKeyValueNumber(stream, entry.key,
-                                        TIME_FROM_TICK(entry.value.tick));
-                break;
             case VLC_TRACER_STRING:
                 JsonPrintKeyValueLabel(stream, entry.key, entry.value.string);
                 break;


=====================================
src/audio_output/dec.c
=====================================
@@ -473,8 +473,9 @@ static void stream_HandleDrift(vlc_aout_stream *stream, vlc_tick_t drift,
     struct vlc_tracer *tracer = aout_stream_tracer(stream);
     if (tracer != NULL)
         vlc_tracer_Trace(tracer, VLC_TRACE("type", "RENDER"),
-                         VLC_TRACE("id", stream->str_id),
-                         VLC_TRACE("drift", drift), VLC_TRACE_END);
+                                 VLC_TRACE("id", stream->str_id),
+                                 VLC_TRACE_TICK_NS("drift", drift),
+                                 VLC_TRACE_END);
 
     /* Following calculations expect an opposite drift. Indeed,
      * vlc_clock_Update() returns a positive relative time, corresponding to


=====================================
src/clock/clock.c
=====================================
@@ -191,9 +191,10 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
             system_now - ((vlc_tick_t) (ts * main_clock->coeff / rate));
 
         if (main_clock->tracer != NULL && clock->track_str_id)
-            vlc_tracer_Trace(main_clock->tracer, VLC_TRACE("type", "RENDER"),
+            vlc_tracer_Trace(main_clock->tracer,
+                             VLC_TRACE("type", "RENDER"),
                              VLC_TRACE("id", clock->track_str_id),
-                             VLC_TRACE("offset", main_clock->offset),
+                             VLC_TRACE_TICK_NS("offset", main_clock->offset),
                              VLC_TRACE_END);
 
         main_clock->last = clock_point_Create(system_now, ts);


=====================================
src/video_output/video_output.c
=====================================
@@ -1381,9 +1381,11 @@ static int RenderPicture(vout_thread_sys_t *sys, bool render_now)
     vout_statistic_AddDisplayed(&sys->statistic, 1);
 
     if (tracer != NULL && system_pts != VLC_TICK_MAX)
-        vlc_tracer_TraceWithTs(tracer, system_pts, VLC_TRACE("type", "RENDER"),
+        vlc_tracer_TraceWithTs(tracer, system_pts,
+                               VLC_TRACE("type", "RENDER"),
                                VLC_TRACE("id", sys->str_id),
-                               VLC_TRACE("drift", drift), VLC_TRACE_END);
+                               VLC_TRACE_TICK_NS("drift", drift),
+                               VLC_TRACE_END);
 
     return VLC_SUCCESS;
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41d5cedac22aabc47f802abbf5e3e50ba5dd1fa5...cf1489032709bb2fc8f3b70a08fe1ddb669e3464

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41d5cedac22aabc47f802abbf5e3e50ba5dd1fa5...cf1489032709bb2fc8f3b70a08fe1ddb669e3464
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list