]> git.sesse.net Git - vlc/commitdiff
src/misc/mtime.c:
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 27 May 2006 17:40:15 +0000 (17:40 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 27 May 2006 17:40:15 +0000 (17:40 +0000)
 - Don't use TIMER_ABSTIME which sucks (at least on Linux with HZ=1000)
 - Cosmetic
configure.ac:
 - Check for clock_nanosleep() rather than clock_gettime(), as it is more
   recent and we need both.

configure.ac
src/misc/mtime.c

index 96d09dc43ab055b9b30d7fb6466d3f48e7513a40..b17892c09a7a980ab14fd7be80151a8d91428e17 100644 (file)
@@ -720,9 +720,9 @@ VLC_ADD_LDFLAGS([vlc plugin],[${THREAD_LIB}])
 
 dnl Don't link with rt when using GNU-pth
 if test "${THREAD_LIB}" != "-lpth" && test "${THREAD_LIB}" != "-lst"; then
-  AC_CHECK_LIB(rt, clock_gettime, [
+  AC_CHECK_LIB(rt, clock_nanosleep, [
     VLC_ADD_LDFLAGS([vlc],[-lrt])
-    AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define to 1 if you have clock_gettime.])
+    AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define to 1 if you have clock_nanosleep.])
   ], [
     dnl HP/UX port
     AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LDFLAGS([vlc],[-lrt])])
index b80d19b4b2fc665f1007dbb433543781c3067853..c8431e1cbee496dcc64fc1dfaa4947f0eb8e17a7 100644 (file)
@@ -187,7 +187,7 @@ mtime_t mdate( void )
         return usec_time;
     }
 
-#elif defined (HAVE_CLOCK_GETTIME)
+#elif defined (HAVE_CLOCK_NANOSLEEP)
     struct timespec ts;
 
 # if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
@@ -239,14 +239,21 @@ void mwait( mtime_t date )
     }
     msleep( delay );
 
-#elif defined (HAVE_CLOCK_GETTIME)
+#elif defined (HAVE_CLOCK_NANOSLEEP)
+# if defined (HAVE_TIMER_ABSTIME_THAT_ACTUALLY_WORKS_WELL)
     lldiv_t d = lldiv( date, 1000000 );
     struct timespec ts = { d.quot, d.rem };
 
-# if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
+#  if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
     if( clock_nanosleep( CLOCK_MONOTONIC, TIMER_ABSTIME, &ts, NULL ) )
-# endif
+#  endif
         clock_nanosleep( CLOCK_REALTIME, TIMER_ABSTIME, &ts, NULL );
+# else
+    date -= mdate ();
+    if( date <= 0)
+        return;
+    msleep( date );
+# endif
 #else
 
     struct timeval tv_date;
@@ -316,11 +323,12 @@ void msleep( mtime_t delay )
 #elif defined( WIN32 ) || defined( UNDER_CE )
     Sleep( (int) (delay / 1000) );
 
-#elif defined( HAVE_CLOCK_GETTIME )
+#elif defined( HAVE_CLOCK_NANOSLEEP ) 
     lldiv_t d = lldiv( delay, 1000000 );
     struct timespec ts = { d.quot, d.rem * 1000 };
+
 # if (_POSIX_CLOCK_MONOTONIC - 0 >= 0)
-    if (clock_nanosleep( CLOCK_MONOTONIC, 0, &ts, NULL ) )
+    ifclock_nanosleep( CLOCK_MONOTONIC, 0, &ts, NULL ) )
 # endif
         clock_nanosleep( CLOCK_REALTIME, 0, &ts, NULL );