aboutsummaryrefslogtreecommitdiff
path: root/utils/midiplay
diff options
context:
space:
mode:
Diffstat (limited to 'utils/midiplay')
-rw-r--r--utils/midiplay/adlmidiplay.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp
index 40cfa41..f5fb855 100644
--- a/utils/midiplay/adlmidiplay.cpp
+++ b/utils/midiplay/adlmidiplay.cpp
@@ -35,9 +35,14 @@
#include <signal.h>
#include <stdint.h>
+
#if defined(ADLMIDI_ENABLE_HW_SERIAL) && !defined(OUTPUT_WAVE_ONLY)
# ifdef ADLMIDI_USE_SDL2
# include <SDL2/SDL_timer.h>
+#ifdef __APPLE__
+# include <unistd.h>
+#endif
+
static inline double s_getTime()
{
return SDL_GetTicks64() / 1000.0;
@@ -45,7 +50,17 @@ static inline double s_getTime()
static inline void s_sleepU(double s)
{
+#ifdef __APPLE__
+ static double debt = 0.0;
+ double target = s_getTime() + s - debt;
+
+ while(s_getTime() < target)
+ usleep(100);
+
+ debt = s_getTime() - target;
+#else
SDL_Delay((Uint32)(s * 1000));
+#endif
}
# else