diff options
author | Wohlstand <admin@wohlnet.ru> | 2024-08-02 08:50:45 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2024-08-02 08:50:45 +0300 |
commit | e9c3ac5c9679fa6418cfd7c9b53bf51dabdf9599 (patch) | |
tree | f504685ff08872abb2167a477a7d33b9f31f4a38 /utils | |
parent | 581bb81a01e862be519b7d8b86f1c260c19fc3f2 (diff) | |
download | libADLMIDI-e9c3ac5c9679fa6418cfd7c9b53bf51dabdf9599.tar.gz libADLMIDI-e9c3ac5c9679fa6418cfd7c9b53bf51dabdf9599.tar.bz2 libADLMIDI-e9c3ac5c9679fa6418cfd7c9b53bf51dabdf9599.zip |
MidiPlay: Tweaked the non-SDL2 timer
This works on Windows with MinGW-w64, but won't work with MSVC because of unistd features.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/midiplay/adlmidiplay.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp index b61f1b6..4b44678 100644 --- a/utils/midiplay/adlmidiplay.cpp +++ b/utils/midiplay/adlmidiplay.cpp @@ -55,7 +55,7 @@ static inline void s_sleepU(double s) double target = s_getTime() + s - debt; while(s_getTime() < target) - usleep(100); + usleep(1000); debt = s_getTime() - target; #else @@ -76,7 +76,13 @@ static inline double s_getTime() static inline void s_sleepU(double s) { - usleep((uint32_t)(s * 1000000)); + static double debt = 0.0; + double target = s_getTime() + s - debt; + + while(s_getTime() < target) + usleep(1000); + + debt = s_getTime() - target; } # endif #endif |