From: Jinoh Kang jinoh.kang.kr@gmail.com
Fixes: f768d6b31bebc35fbaf751d0cd57c8bd302a8d60 --- libs/fluidsynth/glib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libs/fluidsynth/glib.c b/libs/fluidsynth/glib.c index cd938a4fb6b..a399850c915 100644 --- a/libs/fluidsynth/glib.c +++ b/libs/fluidsynth/glib.c @@ -40,10 +40,14 @@ int g_snprintf( char *buffer, size_t size, const char *format, ... )
double g_get_monotonic_time(void) { - static LARGE_INTEGER frequency = {0}; - LARGE_INTEGER counter; + static volatile LONG64 freq_cache; + LARGE_INTEGER counter, frequency;
- if (!frequency.QuadPart) QueryPerformanceFrequency( &frequency ); + if (!(frequency.QuadPart = ReadNoFence64( &freq_cache ))) + { + QueryPerformanceFrequency( &frequency ); + WriteNoFence64( &freq_cache, frequency.QuadPart ); + } QueryPerformanceCounter( &counter );
return counter.QuadPart * 1000000.0 / frequency.QuadPart; /* time in micros */