]> git.sesse.net Git - vlc/commitdiff
win32: query performance timer frequency just once at start
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 17 Apr 2012 20:03:50 +0000 (23:03 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 17 Apr 2012 20:22:23 +0000 (23:22 +0300)
src/win32/thread.c

index d16f4fe2147284af6346e4222db249ca4ac3b756..45f94fd4fd209a297464bd9dbec2cce9c72713b8 100644 (file)
@@ -61,6 +61,7 @@ struct vlc_thread
     void          *data;
 };
 
+static LARGE_INTEGER freq;
 static vlc_mutex_t super_mutex;
 static vlc_cond_t  super_variable;
 extern vlc_rwlock_t config_lock, msg_lock;
@@ -75,6 +76,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
     switch (fdwReason)
     {
         case DLL_PROCESS_ATTACH:
+            if (!QueryPerformanceFrequency (&freq))
+                return FALSE;
             vlc_mutex_init (&super_mutex);
             vlc_cond_init (&super_variable);
             vlc_threadvar_create (&thread_key, NULL);
@@ -771,10 +774,9 @@ void vlc_control_cancel (int cmd, ...)
 mtime_t mdate (void)
 {
     /* We don't need the real date, just the value of a high precision timer */
-    LARGE_INTEGER counter, freq;
-    if (!QueryPerformanceCounter (&counter)
-     || !QueryPerformanceFrequency (&freq))
-        abort();
+    LARGE_INTEGER counter;
+    if (!QueryPerformanceCounter (&counter))
+        abort ();
 
     /* Convert to from (1/freq) to microsecond resolution */
     /* We need to split the division to avoid 63-bits overflow */