[vlc-commits] [Git][videolan/vlc][master] 4 commits: tracer: move tick conversion in modules
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sat May 14 07:03:55 UTC 2022
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
425f4424 by Thomas Guillem at 2022-05-14T06:48:20+00:00
tracer: move tick conversion in modules
- - - - -
3f0b8717 by Thomas Guillem at 2022-05-14T06:48:20+00:00
tracer: pass the timestamp to modules
To let tracer users send their own timestamp.
- - - - -
61ab760c by Thomas Guillem at 2022-05-14T06:48:20+00:00
tracer: add the ability to specify the timestamp
- - - - -
e6cfc52c by Thomas Guillem at 2022-05-14T06:48:20+00:00
tracer: trace render_pts
Mostly convenient for the audio output since the render date are in the
fure (the aout delay).
- - - - -
4 changed files:
- include/vlc_tracer.h
- modules/logger/json.c
- src/libvlccore.sym
- src/misc/tracer.c
Changes:
=====================================
include/vlc_tracer.h
=====================================
@@ -43,17 +43,17 @@
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;
-#define VLC_TRACER_TIME_FROM_TICK(ts) NS_FROM_VLC_TICK(ts)
-
/**
* Trace message
*/
@@ -73,7 +73,7 @@ struct vlc_tracer;
* should be ended by a \ref vlc_tracer_entry with a NULL key.
* \param data data pointer as provided to vlc_tracer_Trace().
*/
-typedef void (*vlc_trace_cb) (void *data, va_list entries);
+typedef void (*vlc_trace_cb) (void *data, vlc_tick_t ts, va_list entries);
struct vlc_tracer_operations
{
@@ -89,8 +89,12 @@ struct vlc_tracer_operations
* Value has to be defined with one of the type defined
* in the \ref vlc_tracer_entry union.
* \param tracer tracer emitting the traces
+ * \param ts timestamp of the current trace
*/
-VLC_API void vlc_tracer_Trace(struct vlc_tracer *tracer, ...);
+VLC_API void vlc_tracer_TraceWithTs(struct vlc_tracer *tracer, vlc_tick_t ts, ...);
+
+#define vlc_tracer_Trace(tracer, ...) \
+ vlc_tracer_TraceWithTs(tracer, vlc_tick_now(), __VA_ARGS__)
/**
* \defgroup tracer Tracer
@@ -102,8 +106,8 @@ VLC_API void vlc_tracer_Trace(struct vlc_tracer *tracer, ...);
static inline struct vlc_tracer_entry vlc_tracer_entry_FromTick(const char *key, vlc_tick_t value)
{
vlc_tracer_value_t tracer_value;
- tracer_value.integer = VLC_TRACER_TIME_FROM_TICK(value);
- struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_INT };
+ tracer_value.integer = value;
+ struct vlc_tracer_entry trace = { key, tracer_value, VLC_TRACER_TICK };
return trace;
}
@@ -170,9 +174,15 @@ static inline void vlc_tracer_TraceRender(struct vlc_tracer *tracer, const char
const char *id, vlc_tick_t now, vlc_tick_t pts)
{
if (now != VLC_TICK_MAX && now != VLC_TICK_INVALID)
- vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
- VLC_TRACE("pts", pts),
- VLC_TRACE("render_ts", now), VLC_TRACE_END);
+ {
+ 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_TRACE_END);
+
+ }
else
vlc_tracer_Trace(tracer, VLC_TRACE("type", type), VLC_TRACE("id", id),
VLC_TRACE("pts", pts), VLC_TRACE_END);
=====================================
modules/logger/json.c
=====================================
@@ -39,6 +39,8 @@
#define JSON_FILENAME "vlc-log.json"
+#define TIME_FROM_TICK(ts) NS_FROM_VLC_TICK(ts)
+
typedef struct
{
FILE *stream;
@@ -154,14 +156,14 @@ static void JsonEndObjectSection(FILE *stream)
fputc('}', stream);
}
-static void TraceJson(void *opaque, va_list entries)
+static void TraceJson(void *opaque, vlc_tick_t ts, va_list entries)
{
vlc_tracer_sys_t *sys = opaque;
FILE* stream = sys->stream;
flockfile(stream);
JsonStartObjectSection(stream, NULL);
- JsonPrintKeyValueNumber(stream, "Timestamp", VLC_TRACER_TIME_FROM_TICK(vlc_tick_now()));
+ JsonPrintKeyValueNumber(stream, "Timestamp", TIME_FROM_TICK(ts));
fputc(',', stream);
JsonStartObjectSection(stream, "Body");
@@ -174,6 +176,10 @@ static void TraceJson(void *opaque, 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/libvlccore.sym
=====================================
@@ -284,7 +284,7 @@ vlc_memstream_printf
vlc_Log
vlc_LogSet
vlc_vaLog
-vlc_tracer_Trace
+vlc_tracer_TraceWithTs
vlc_LogHeaderCreate
vlc_LogDestroy
vlc_strerror
=====================================
src/misc/tracer.c
=====================================
@@ -46,7 +46,7 @@ struct vlc_tracer_module {
void *opaque;
};
-void vlc_tracer_Trace(struct vlc_tracer *tracer, ...)
+void vlc_tracer_TraceWithTs(struct vlc_tracer *tracer, vlc_tick_t ts, ...)
{
assert(tracer->ops->trace != NULL);
struct vlc_tracer_module *module =
@@ -54,8 +54,8 @@ void vlc_tracer_Trace(struct vlc_tracer *tracer, ...)
/* Pass message to the callback */
va_list entries;
- va_start(entries, tracer);
- tracer->ops->trace(module->opaque, entries);
+ va_start(entries, ts);
+ tracer->ops->trace(module->opaque, ts, entries);
va_end(entries);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/31c7dc12042088e3d9f5a806b04e7970490c75c3...e6cfc52cd4de37804b4de879e5aabee4862f1beb
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/31c7dc12042088e3d9f5a806b04e7970490c75c3...e6cfc52cd4de37804b4de879e5aabee4862f1beb
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