Fix OSX builds (amend 04df26244, a2b5962b6)

This commit is contained in:
Robin Gareus 2021-06-27 05:09:07 +02:00
parent b904fdea5d
commit 738b0ad21b
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 29 additions and 30 deletions

View File

@ -927,36 +927,6 @@ ARDOUR::get_available_sync_options ()
return ret;
}
/** Return a monotonic value for the number of microseconds that have elapsed
* since an arbitrary zero origin.
*/
#ifdef __MACH__
/* Thanks Apple for not implementing this basic SUSv2, POSIX.1-2001 function
*/
#include <mach/mach_time.h>
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 0
int
clock_gettime (int /*clk_id*/, struct timespec* t)
{
static bool initialized = false;
static mach_timebase_info_data_t timebase;
if (!initialized) {
mach_timebase_info (&timebase);
initialized = true;
}
uint64_t time;
time = mach_absolute_time ();
double nseconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom);
double seconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom * 1e9);
t->tv_sec = seconds;
t->tv_nsec = nseconds;
return 0;
}
#endif
/** Return the number of bits per sample for a given sample format.
*
* This is closely related to sndfile_data_width() but does NOT

View File

@ -33,6 +33,35 @@
static double timer_rate_usecs = 0.0;
#endif
/** Return a monotonic value for the number of microseconds that have elapsed
* since an arbitrary zero origin.
*/
#ifdef __MACH__
/* Thanks Apple for not implementing this basic SUSv2, POSIX.1-2001 function
*/
#include <mach/mach_time.h>
#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 0
int
clock_gettime (int /*clk_id*/, struct timespec* t)
{
static bool initialized = false;
static mach_timebase_info_data_t timebase;
if (!initialized) {
mach_timebase_info (&timebase);
initialized = true;
}
uint64_t time;
time = mach_absolute_time ();
double nseconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom);
double seconds = ((double)time * (double)timebase.numer) / ((double)timebase.denom * 1e9);
t->tv_sec = seconds;
t->tv_nsec = nseconds;
return 0;
}
#endif
void
PBD::microsecond_timer_init ()
{