MT#55283 convert now_double to int64_t

Change-Id: I305415a7edc5593d82acf3be1ce6820627c050de
pull/1855/merge
Richard Fuchs 1 week ago
parent 8994c59cc9
commit 2cda41718a

@ -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);

@ -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) {

@ -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);

@ -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;
}

@ -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 <time.h>
#include <sys/time.h>
#include "compat.h"
INLINE double now_double(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + tv.tv_usec / 1000000.0;
}
#endif

@ -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;

@ -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;

Loading…
Cancel
Save