Commit bfb09d95 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

snapshot: use timespec_get() (fixes #14008)

parent 064fffbc
......@@ -29,7 +29,6 @@
#include <assert.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <dirent.h>
#include <time.h>
......@@ -180,20 +179,20 @@ int vout_snapshot_SaveImage(char **name, int *sequential,
free(filename);
}
} else {
struct timeval tv;
struct timespec ts;
struct tm curtime;
char buffer[128];
gettimeofday(&tv, NULL);
if (localtime_r(&tv.tv_sec, &curtime) == NULL)
gmtime_r(&tv.tv_sec, &curtime);
timespec_get(&ts, TIME_UTC);
if (localtime_r(&ts.tv_sec, &curtime) == NULL)
gmtime_r(&ts.tv_sec, &curtime);
if (strftime(buffer, sizeof(buffer), "%Y-%m-%d-%Hh%Mm%Ss",
&curtime) == 0)
strcpy(buffer, "error");
if (asprintf(&filename, "%s" DIR_SEP "%s%s%03u.%s",
cfg->path, prefix, buffer,
(unsigned)tv.tv_usec / 1000, cfg->format) < 0)
if (asprintf(&filename, "%s" DIR_SEP "%s%s%03lu.%s",
cfg->path, prefix, buffer, ts.tv_nsec / 1000000,
cfg->format) < 0)
filename = NULL;
}
free(prefix);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment