diff --git a/src/drivers/fluid_jack.c b/src/drivers/fluid_jack.c index 43f6203b..4eec1682 100644 --- a/src/drivers/fluid_jack.c +++ b/src/drivers/fluid_jack.c @@ -391,7 +391,7 @@ fluid_jack_client_close (fluid_jack_client_t *client_ref, void *driver) if (client_ref->audio_driver || client_ref->midi_driver) { - g_usleep (100000); /* FIXME - Hack to make sure that resources don't get freed while Jack callback is active */ + fluid_msleep(100); /* FIXME - Hack to make sure that resources don't get freed while Jack callback is active */ return; } diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c index 6fb98f95..bbe3fb7a 100644 --- a/src/midi/fluid_midi.c +++ b/src/midi/fluid_midi.c @@ -1823,11 +1823,7 @@ fluid_player_join(fluid_player_t *player) } else if (player->sample_timer) { /* Busy-wait loop, since there's no thread to wait for... */ while (player->status != FLUID_PLAYER_DONE) { -#if defined(WIN32) - Sleep(10); -#else - usleep(10000); -#endif + fluid_msleep(10); } } return FLUID_OK; diff --git a/src/utils/fluid_sys.c b/src/utils/fluid_sys.c index 41d102c5..226035d1 100644 --- a/src/utils/fluid_sys.c +++ b/src/utils/fluid_sys.c @@ -344,6 +344,15 @@ fluid_is_soundfont(const char *filename) return strncmp(id, "RIFF", 4) == 0; } +/** + * Suspend the execution of the current thread for the specified amount of time. + * @param milliseconds to wait. + */ +void fluid_msleep(unsigned int msecs) +{ + g_usleep(msecs * 1000); +} + /** * Get time in milliseconds to be used in relative timing operations. * @return Unix time in milliseconds. @@ -692,7 +701,7 @@ fluid_timer_run (void *data) two callbacks bringing in the "absolute" time (count * timer->msec) */ delay = (count * timer->msec) - (fluid_curtime() - start); - if (delay > 0) g_usleep (delay * 1000); + if (delay > 0) fluid_msleep(delay); } FLUID_LOG (FLUID_DBG, "Timer thread finished"); diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index d86d17ae..44ef3e02 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -460,4 +460,7 @@ extern fluid_profile_data_t fluid_profile_data[]; unsigned int fluid_check_fpe_i386(char * explanation_in_case_of_fpe); void fluid_clear_fpe_i386(void); +/* System control */ +void fluid_msleep(unsigned int msecs); + #endif /* _FLUID_SYS_H */