aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorWohlstand <Wohlstand@users.noreply.github.com>2024-08-01 08:43:40 +0300
committerWohlstand <Wohlstand@users.noreply.github.com>2024-08-01 08:43:40 +0300
commit525e31073530115fe0500c7da006aaf7019c9aa1 (patch)
tree2908543247aa30c3827a8676d6202daa98771e20 /utils
parent68867c104834d65824f35cff9019549880ae6d5b (diff)
downloadlibADLMIDI-525e31073530115fe0500c7da006aaf7019c9aa1.tar.gz
libADLMIDI-525e31073530115fe0500c7da006aaf7019c9aa1.tar.bz2
libADLMIDI-525e31073530115fe0500c7da006aaf7019c9aa1.zip
MidiPlay: Added an ugly workaround for macOS
If the real sleep functions doesn't work as supposed, then, I will make own, ~~with blackjack and hookers~~ that tracks the clock to simulate the sleep.
Diffstat (limited to 'utils')
-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