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
13 * Authors: Vincent Seguin <seguin@via.ecp.fr>
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
28 *****************************************************************************/
30 /*****************************************************************************
33 * this header includes inline functions
34 *****************************************************************************/
36 /*****************************************************************************
37 * mtime_t: high precision date or time interval
38 *****************************************************************************
39 * Store an high precision date or time interval. The maximum precision is the
40 * micro-second, and a 64 bits integer is used to avoid any overflow (maximum
41 * time interval is then 292271 years, which should be length enough for any
42 * video). Date are stored as a time interval since a common date.
43 * Note that date and time intervals can be manipulated using regular arithmetic
44 * operators, and that no special functions are required.
45 *****************************************************************************/
48 /*****************************************************************************
49 * LAST_MDATE: date which will never happen
50 *****************************************************************************
51 * This date can be used as a 'never' date, to mark missing events in a function
52 * supposed to return a date, such as nothing to display in a function
53 * returning the date of the first image to be displayed. It can be used in
54 * comparaison with other values: all existing dates will be earlier.
55 *****************************************************************************/
56 #define LAST_MDATE ((mtime_t)((u64)(-1)/2))
58 /*****************************************************************************
59 * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
60 *****************************************************************************
61 * This values is the maximal possible size of the string returned by the
62 * mstrtime() function, including '-' and the final '\0'. It should be used to
63 * allocate the buffer.
64 *****************************************************************************/
65 #define MSTRTIME_MAX_SIZE 22
67 /*****************************************************************************
69 *****************************************************************************/
70 char * mstrtime ( char *psz_buffer, mtime_t date );
71 mtime_t mdate ( void );
72 void mwait ( mtime_t date );
73 void msleep ( mtime_t delay );