Rewrote dump_video example to prefer clock_gettime() over ftime().
The ftime method has been removed from POSIX and is depricated on Linux. clock_gettime() work better on Linux, but is not available on Windows, so fall back to ftime() if autotools/scons fail to detect clock_gettime().
Based on proposal in opusfile!9 (closed).
Fixes the following compiler messages:
../../examples/dump_video.c: In function ‘main’:
../../examples/dump_video.c:490:5: warning: ‘ftime’ is deprecated: Use gettimeofday or clock_gettime instead [-Werror=deprecated-declarations]
490 | ftime(&start);
| ^~~~~
In file included from ../../examples/dump_video.c:40:
/usr/include/x86_64-linux-gnu/sys/timeb.h:29:12: note: declared here
29 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
../../examples/dump_video.c:491:5: warning: ‘ftime’ is deprecated: Use gettimeofday or clock_gettime instead [-Werror=deprecated-declarations]
491 | ftime(&last);
| ^~~~~
/usr/include/x86_64-linux-gnu/sys/timeb.h:29:12: note: declared here
29 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
../../examples/dump_video.c:505:13: warning: ‘ftime’ is deprecated: Use gettimeofday or clock_gettime instead [-Werror=deprecated-declarations]
505 | ftime(&after);
| ^~~~~
/usr/include/x86_64-linux-gnu/sys/timeb.h:29:12: note: declared here
29 | extern int ftime (struct timeb *__timebuf)
| ^~~~~
Merge request reports
Activity
The problem is that despite the deprecation of ftime() in 2020, I don't believe that MSVC supports gettimeofday(). ftime() was chosen because it was the only standard(ish) API that was available on both POSIX and Windows systems that gave sub-second resolution.
Please see opusfile!9 (closed) for the approach we took to handle this in opusfile.
added 1 commit
- b05e8ec6 - Replaced use of obsolete ftime() with gettimeofday().
added 1 commit
- 2e1cd694 - Rewrote to use ftime() when clock_gettime() to work with Windows.
I adjusted the proposal based on opusfile!9 (closed), dropping use some internal macros. If this approach is accepted, I will squash the merges before it should go into master.
added 3 commits
-
2e1cd694...3446dd66 - 2 commits from branch
master
- ec5129f0 - Rewrote dump_video example to prefer clock_gettime() over ftime()
-
2e1cd694...3446dd66 - 2 commits from branch
added 4 commits
-
ec5129f0...47388cd8 - 3 commits from branch
master
- a4dff816 - Rewrote dump_video example to prefer clock_gettime() over ftime()
-
ec5129f0...47388cd8 - 3 commits from branch