From 83e6fb8ddeea7fa704a9a379f2c3b2a55df9954a Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Tue, 21 Sep 2021 00:39:12 +0200 Subject: [PATCH] Add CLOCK_MONOTONIC_RAW as second audio log clock I've had to correct part of the sound effects during editing because they were logged to have happened like 0-2 seconds late, I didn't know you could also choose a different clock. Let's choose the "raw hard- ware-based time that is not subject to NTP adjustments or the incremental adjustments performed by adjtime(3)." See clock_gettime(2) --- desktop_version/src/Music.cpp | 9 +++++++-- desktop_version/src/Music.h | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index 56c0e1129b..1bb1f52e09 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -35,8 +35,13 @@ musicclass::musicclass(void) void musicclass::audio_log_set_timestamp(void) { - clock_gettime(CLOCK_REALTIME, &audio_log_t); - sprintf(audio_log_timestring_lol, "%lu.%lu", audio_log_t.tv_sec, audio_log_t.tv_nsec); + clock_gettime(CLOCK_REALTIME, &audio_log_t_realtime); + clock_gettime(CLOCK_MONOTONIC_RAW, &audio_log_t_monotonic); + + sprintf(audio_log_timestring_lol, "%lu.%lu;%lu.%lu", + audio_log_t_realtime.tv_sec, audio_log_t_realtime.tv_nsec, + audio_log_t_monotonic.tv_sec, audio_log_t_monotonic.tv_nsec + ); } void musicclass::start_audio_log(void) diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index b6b95fa78f..29b86610e0 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -80,7 +80,8 @@ class musicclass int num_mmmmmm_tracks; // Audio log - struct timespec audio_log_t; + struct timespec audio_log_t_realtime; + struct timespec audio_log_t_monotonic; char audio_log_timestring_lol[100]; bool audio_log_started;