From 2cda41718ab5891e570b97e085faa78e12595f4f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 15 Apr 2025 11:01:39 -0400 Subject: [PATCH] MT#55283 convert now_double to int64_t Change-Id: I305415a7edc5593d82acf3be1ce6820627c050de --- recording-daemon/db.c | 19 ++++++++++--------- recording-daemon/metafile.c | 2 +- recording-daemon/notify.c | 6 +++--- recording-daemon/output.c | 2 +- recording-daemon/recaux.h | 12 ------------ recording-daemon/stream.c | 2 +- recording-daemon/types.h | 6 +++--- 7 files changed, 19 insertions(+), 30 deletions(-) diff --git a/recording-daemon/db.c b/recording-daemon/db.c index 7b60c091c..85721a883 100644 --- a/recording-daemon/db.c +++ b/recording-daemon/db.c @@ -202,11 +202,12 @@ INLINE void my_i(MYSQL_BIND *b, const int *i) { .is_unsigned = 0, }; } -INLINE void my_d(MYSQL_BIND *b, const double *d) { +INLINE void my_ts(MYSQL_BIND *b, int64_t ts) { + double d = (double) ts / 1000000.; *b = (MYSQL_BIND) { .buffer_type = MYSQL_TYPE_DOUBLE, - .buffer = (void *) d, - .buffer_length = sizeof(*d), + .buffer = (void *) &d, + .buffer_length = sizeof(d), .is_unsigned = 0, }; } @@ -260,7 +261,7 @@ static void db_do_call_id(metafile_t *mf) { MYSQL_BIND b[2]; my_cstr(&b[0], mf->call_id); - my_d(&b[1], &mf->start_time); + my_ts(&b[1], mf->start_time_us); execute_wrap(&stm_insert_call, b, &mf->db_id); } @@ -339,7 +340,7 @@ void db_do_stream(metafile_t *mf, output_t *op, stream_t *stream, unsigned long } else my_cstr(&b[9], ""); - my_d(&b[10], &op->start_time); + my_ts(&b[10], op->start_time_us); execute_wrap(&stm_insert_stream, b, &op->db_id); @@ -353,12 +354,12 @@ void db_close_call(metafile_t *mf) { if (mf->db_id == 0) return; - double now = now_double(); + int64_t now = now_us(); MYSQL_BIND b[2]; if (mf->db_streams > 0) { - my_d(&b[0], &now); + my_ts(&b[0], now); my_ull(&b[1], &mf->db_id); execute_wrap(&stm_close_call, b, NULL); } @@ -375,7 +376,7 @@ void db_close_stream(output_t *op) { if (op->db_id == 0) return; - double now = now_double(); + int64_t now = now_us(); str stream = STR_NULL; MYSQL_BIND b[3]; @@ -417,7 +418,7 @@ void db_close_stream(output_t *op) { file:; int par_idx = 0; - my_d(&b[par_idx++], &now); + my_ts(&b[par_idx++], now); if ((output_storage & OUTPUT_STORAGE_DB)) my_str(&b[par_idx++], &stream); my_ull(&b[par_idx++], &op->db_id); diff --git a/recording-daemon/metafile.c b/recording-daemon/metafile.c index 513486a43..6703dea33 100644 --- a/recording-daemon/metafile.c +++ b/recording-daemon/metafile.c @@ -283,7 +283,7 @@ static metafile_t *metafile_get(char *name) { mf->forward_count = 0; mf->forward_failed = 0; mf->recording_on = 1; - mf->start_time = now_double(); + mf->start_time_us = now_us(); mf->metadata_parsed = metadata_ht_new(); if (decoding_enabled) { diff --git a/recording-daemon/notify.c b/recording-daemon/notify.c index cc2889392..053a61fc1 100644 --- a/recording-daemon/notify.c +++ b/recording-daemon/notify.c @@ -291,15 +291,15 @@ void notify_push_output(output_t *o, metafile_t *mf, tag_t *tag) { req->name = g_strdup(o->file_name); req->full_filename_path = g_strdup_printf("%s.%s", o->full_filename, o->file_format); - double now = now_double(); + double now = (double) now_us() / 1000000.; notify_add_header(req, "X-Recording-Call-ID: %s", mf->call_id); notify_add_header(req, "X-Recording-File-Name: %s.%s", o->file_name, o->file_format); notify_add_header(req, "X-Recording-Full-File-Name: %s.%s", o->full_filename, o->file_format); notify_add_header(req, "X-Recording-File-Format: %s", o->file_format); notify_add_header(req, "X-Recording-Kind: %s", o->kind); - notify_add_header(req, "X-Recording-Call-Start-Time: %.06f", mf->start_time); - notify_add_header(req, "X-Recording-Stream-Start-Time: %.06f", o->start_time); + notify_add_header(req, "X-Recording-Call-Start-Time: %.06f", (double) mf->start_time_us / 1000000.); + notify_add_header(req, "X-Recording-Stream-Start-Time: %.06f", (double) o->start_time_us / 1000000.); notify_add_header(req, "X-Recording-Call-End-Time: %.06f", now); notify_add_header(req, "X-Recording-Stream-End-Time: %.06f", now); diff --git a/recording-daemon/output.c b/recording-daemon/output.c index 2506eff5f..1f4b7f658 100644 --- a/recording-daemon/output.c +++ b/recording-daemon/output.c @@ -95,7 +95,7 @@ static output_t *output_alloc(const char *path, const char *name) { ret->channel_mult = 1; ret->requested_format.format = -1; ret->actual_format.format = -1; - ret->start_time = now_double(); + ret->start_time_us = now_us(); return ret; } diff --git a/recording-daemon/recaux.h b/recording-daemon/recaux.h index 3f65f3cc9..876dcddd4 100644 --- a/recording-daemon/recaux.h +++ b/recording-daemon/recaux.h @@ -6,16 +6,4 @@ extern __thread int __sscanf_hack_var; #define sscanf_match(str, format, ...) __sscanf_match(str, format "%n", ##__VA_ARGS__, &__sscanf_hack_var) int __sscanf_match(const char *str, const char *fmt, ...) __attribute__ ((__format__ (__scanf__, 2, 3))); - -#include -#include -#include "compat.h" - -INLINE double now_double(void) { - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec + tv.tv_usec / 1000000.0; -} - - #endif diff --git a/recording-daemon/stream.c b/recording-daemon/stream.c index efc75d9e5..f6056623f 100644 --- a/recording-daemon/stream.c +++ b/recording-daemon/stream.c @@ -108,7 +108,7 @@ static stream_t *stream_get(metafile_t *mf, unsigned long id) { ret->id = id; ret->metafile = mf; ret->tag = (unsigned long) -1; - ret->start_time = now_double(); + ret->start_time_us = now_us(); out: return ret; diff --git a/recording-daemon/types.h b/recording-daemon/types.h index 226ac6387..9e1a9df5c 100644 --- a/recording-daemon/types.h +++ b/recording-daemon/types.h @@ -56,7 +56,7 @@ struct stream_s { int fd; handler_t handler; unsigned int forwarding_on:1; - double start_time; + int64_t start_time_us; unsigned int media_sdp_id; unsigned int channel_slot; }; @@ -132,7 +132,7 @@ struct metafile_s { off_t pos; unsigned long long db_id; unsigned int db_streams; - double start_time; + int64_t start_time_us; GStringChunk *gsc; // XXX limit max size @@ -172,7 +172,7 @@ struct output_s { unsigned long long db_id; gboolean skip_filename_extension; unsigned int channel_mult; - double start_time; + int64_t start_time_us; AVFormatContext *fmtctx; AVStream *avst;