[FFmpeg-cvslog] avutil/tile: check clock_gettime at runtime for apple platforms
Wang Bin
git at videolan.org
Mon Jan 9 05:54:01 EET 2017
ffmpeg | branch: master | Wang Bin <wbsecg1 at gmail.com> | Mon Jan 9 11:52:06 2017 +0800| [0e8b68a2c4031e25082603ad88711be12210d41f] | committer: Steven Liu
avutil/tile: check clock_gettime at runtime for apple platforms
clock_gettime is avalible since macOS 10.12 and iOS 10.0. Because of
weak linking, clock_gettime can be build without error with new
macOS/iOS sdk, but the symbol may not exist on the target system.
Explicitly checking the symbol is required.
https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
Signed-off-by: Wang Bin <wbsecg1 at gmail.com>
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e8b68a2c4031e25082603ad88711be12210d41f
---
libavutil/time.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/libavutil/time.c b/libavutil/time.c
index dbaee02..afa6658 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -56,17 +56,25 @@ int64_t av_gettime(void)
int64_t av_gettime_relative(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
-#else
- return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
+#ifdef __APPLE__
+ if (clock_gettime)
+#endif
+ {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+ }
#endif
+ return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
}
int av_gettime_relative_is_monotonic(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
+#ifdef __APPLE__
+ if (!clock_gettime)
+ return 0;
+#endif
return 1;
#else
return 0;
More information about the ffmpeg-cvslog
mailing list