1 /*****************************************************************************
2 * mtime.h: high resolution time management functions
3 * This header provides portable high precision time management functions,
4 * which should be the only ones used in other segments of the program, since
5 * functions like gettimeofday() and ftime() are not always supported.
6 * Most functions are declared as inline or as macros since they are only
7 * interfaces to system calls and have to be called frequently.
8 * 'm' stands for 'micro', since maximum resolution is the microsecond.
9 * Functions prototyped are implemented in interface/mtime.c.
10 *****************************************************************************
11 * Copyright (C) 1996, 1997, 1998, 1999, 2000 VideoLAN
12 * $Id: mtime.h,v 1.7 2001/03/21 13:42:33 sam Exp $
14 * Authors: Vincent Seguin <seguin@via.ecp.fr>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
29 *****************************************************************************/
31 /*****************************************************************************
34 * this header includes inline functions
35 *****************************************************************************/
37 /*****************************************************************************
38 * mtime_t: high precision date or time interval
39 *****************************************************************************
40 * Store an high precision date or time interval. The maximum precision is the
41 * micro-second, and a 64 bits integer is used to avoid any overflow (maximum
42 * time interval is then 292271 years, which should be length enough for any
43 * video). Date are stored as a time interval since a common date.
44 * Note that date and time intervals can be manipulated using regular arithmetic
45 * operators, and that no special functions are required.
46 *****************************************************************************/
49 /*****************************************************************************
50 * LAST_MDATE: date which will never happen
51 *****************************************************************************
52 * This date can be used as a 'never' date, to mark missing events in a function
53 * supposed to return a date, such as nothing to display in a function
54 * returning the date of the first image to be displayed. It can be used in
55 * comparaison with other values: all existing dates will be earlier.
56 *****************************************************************************/
57 #define LAST_MDATE ((mtime_t)((u64)(-1)/2))
59 /*****************************************************************************
60 * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
61 *****************************************************************************
62 * This values is the maximal possible size of the string returned by the
63 * mstrtime() function, including '-' and the final '\0'. It should be used to
64 * allocate the buffer.
65 *****************************************************************************/
66 #define MSTRTIME_MAX_SIZE 22
68 /*****************************************************************************
70 *****************************************************************************/
71 char * mstrtime ( char *psz_buffer, mtime_t date );
72 mtime_t mdate ( void );
73 void mwait ( mtime_t date );
74 void msleep ( mtime_t delay );