]> git.sesse.net Git - vlc/blobdiff - src/misc/mtime.c
Fixed compliation error due to inclusion of threads.h
[vlc] / src / misc / mtime.c
index d8445581e14d449840d8a67e7180dde7ae8edca6..140752c925626f7d4a30e893047f0403dfe8e2a6 100644 (file)
@@ -2,8 +2,8 @@
  * mtime.c: high rezolution time management functions
  * Functions are prototyped in mtime.h.
  *****************************************************************************
- * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: mtime.c,v 1.23 2001/06/14 20:21:04 sam Exp $
+ * Copyright (C) 1998-2001 VideoLAN
+ * $Id: mtime.c,v 1.27 2001/12/30 07:09:56 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <stdio.h>                                              /* sprintf() */
 
+#include <videolan/vlc.h>
+
 #if defined( PTH_INIT_IN_PTH_H )                                  /* GNU Pth */
 #   include <pth.h>
 #endif
 #   include <sys/time.h>
 #endif
 
-#include "config.h"
-#include "common.h"
-#include "mtime.h"
-
-#if defined( WIN32 )
-/*****************************************************************************
- * usleep: microsecond sleep for win32
- *****************************************************************************
- * This function uses performance counter if available, and Sleep() if not.
- *****************************************************************************/
-static __inline__ void usleep( unsigned int i_useconds )
-{
-    s64 i_cur, i_freq;
-    s64 i_now, i_then;
-
-    if( i_useconds < 1000
-         && QueryPerformanceFrequency( (LARGE_INTEGER *) &i_freq ) )
-    {
-        QueryPerformanceCounter( (LARGE_INTEGER *) &i_cur );
-
-        i_now = ( i_cur * 1000 * 1000 / i_freq );
-        i_then = i_now + i_useconds;
-
-        while( i_now < i_then )
-        {
-            QueryPerformanceCounter( (LARGE_INTEGER *) &i_cur );
-            i_now = i_cur * 1000 * 1000 / i_freq;
-        }
-    }
-    else
-    {
-        Sleep( (int) ((i_useconds + 500) / 1000) );
-    }
-}
-#endif
-
 /*****************************************************************************
  * mstrtime: return a date in a readable format
  *****************************************************************************
@@ -127,14 +91,12 @@ mtime_t mdate( void )
     {
         /* Microsecond resolution */
         QueryPerformanceCounter( (LARGE_INTEGER *)&usec_time );
-       return ( usec_time * 1000000 ) / freq;
-    }
-    else
-    {
-        /* Milisecond resolution */
-        return 1000 * GetTickCount();
+        return ( usec_time * 1000000 ) / freq;
     }
 
+    /* Milisecond resolution */
+    return 1000 * GetTickCount();
+
 #else
     struct timeval tv_date;
 
@@ -175,8 +137,7 @@ void mwait( mtime_t date )
     {
         return;
     }
-
-    usleep( delay );
+    msleep( delay );
 
 #else
 
@@ -235,9 +196,12 @@ void msleep( mtime_t delay )
     tv_delay.tv_usec = delay % 1000000;
     pth_select( 0, NULL, NULL, NULL, &tv_delay );
 
-#elif defined( HAVE_USLEEP ) || defined( WIN32 )
+#elif defined( HAVE_USLEEP )
     usleep( delay );
 
+#elif defined( WIN32 )
+    Sleep( (int) (delay / 1000) );
+
 #else
     struct timeval tv_delay;