[vlc-commits] snapshot: use timespec_get() (fixes #14008)
Rémi Denis-Courmont
git at videolan.org
Wed Dec 9 18:18:12 CET 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Dec 9 19:15:27 2015 +0200| [bfb09d956f2fe23ef6447ddb6bf5926574dc7b46] | committer: Rémi Denis-Courmont
snapshot: use timespec_get() (fixes #14008)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bfb09d956f2fe23ef6447ddb6bf5926574dc7b46
---
src/video_output/snapshot.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/video_output/snapshot.c b/src/video_output/snapshot.c
index 7c8b527..a37cdf1 100644
--- a/src/video_output/snapshot.c
+++ b/src/video_output/snapshot.c
@@ -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);
More information about the vlc-commits
mailing list