summaryrefslogtreecommitdiffhomepage
path: root/src/external
diff options
context:
space:
mode:
authorRay <[email protected]>2018-02-20 10:30:51 +0100
committerRay <[email protected]>2018-02-20 10:30:51 +0100
commit11612fce272a82e52a1fbc528ee9c0c3f1b4753c (patch)
treedf8a25b06ae9a81411fca76e8b7a6e536e01cd25 /src/external
parent1652943f98086b29bdafc0e42359412a6ad993cd (diff)
downloadraylib-11612fce272a82e52a1fbc528ee9c0c3f1b4753c.tar.gz
raylib-11612fce272a82e52a1fbc528ee9c0c3f1b4753c.zip
Reviewed timming system for macOS
Apparently, before macOS Sierra version, clock_gettime was not available, using MATCH timming system instead
Diffstat (limited to 'src/external')
-rw-r--r--src/external/mini_al.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/external/mini_al.h b/src/external/mini_al.h
index c9ab40fa..1374de5b 100644
--- a/src/external/mini_al.h
+++ b/src/external/mini_al.h
@@ -1557,6 +1557,10 @@ void mal_pcm_convert(void* pOut, mal_format formatOut, const void* pIn, mal_form
#include <string.h> // For memset()
#endif
+#if defined(MAL_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
+#include <mach/mach_time.h> // For mach_absolute_time()
+#endif
+
#ifdef MAL_POSIX
#include <unistd.h>
#include <dlfcn.h>
@@ -2082,6 +2086,24 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
return (counter.QuadPart - pTimer->counter) / (double)g_mal_TimerFrequency.QuadPart;
}
+#elif defined(MAL_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
+static uint64_t g_mal_TimerFrequency = 0;
+void mal_timer_init(mal_timer* pTimer)
+{
+ mach_timebase_info_data_t baseTime;
+ mach_timebase_info(&baseTime);
+ g_mal_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer;
+
+ pTimer->counter = mach_absolute_time();
+}
+
+double mal_timer_get_time_in_seconds(mal_timer* pTimer)
+{
+ uint64_t newTimeCounter = mach_absolute_time();
+ uint64_t oldTimeCounter = pTimer->counter;
+
+ return (newTimeCounter - oldTimeCounter) / g_mal_TimerFrequency;
+}
#else
void mal_timer_init(mal_timer* pTimer)
{