* Functions are prototyped in mtime.h.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
+ * $Id: mtime.c,v 1.16 2001/03/21 13:42:34 sam Exp $
*
- * Authors:
+ * Authors: Vincent Seguin <seguin@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
void mwait( mtime_t date )
{
#ifdef HAVE_KERNEL_OS_H
-
+
mtime_t delay;
delay = date - real_time_clock_usecs();
gettimeofday( &tv_date, NULL );
/* calculate delay and check if current date is before wished date */
- delay = date - (mtime_t) tv_date.tv_sec * 1000000 - (mtime_t) tv_date.tv_usec;
+ delay = date - (mtime_t) tv_date.tv_sec * 1000000 - (mtime_t) tv_date.tv_usec - 10000;
+ /* Linux/i386 has a granularity of 10 ms. It's better to be in advance
+ * than to be late. */
if( delay <= 0 ) /* wished date is now or already passed */
{
return;