[vlc-commits] win32: query performance timer frequency just once at start

Rémi Denis-Courmont git at videolan.org
Tue Apr 17 22:26:17 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Apr 17 23:03:50 2012 +0300| [5ed7f8403e02888b727c18d5644e0314786b169d] | committer: Rémi Denis-Courmont

win32: query performance timer frequency just once at start

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ed7f8403e02888b727c18d5644e0314786b169d
---

 src/win32/thread.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index d16f4fe..45f94fd 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -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 */



More information about the vlc-commits mailing list