Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

mtime.h

00001 /*****************************************************************************
00002  * mtime.h: high resolution time management functions
00003  * This header provides portable high precision time management functions,
00004  * which should be the only ones used in other segments of the program, since
00005  * functions like gettimeofday() and ftime() are not always supported.
00006  * Most functions are declared as inline or as macros since they are only
00007  * interfaces to system calls and have to be called frequently.
00008  * 'm' stands for 'micro', since maximum resolution is the microsecond.
00009  * Functions prototyped are implemented in interface/mtime.c.
00010  *****************************************************************************
00011  * Copyright (C) 1996, 1997, 1998, 1999, 2000 the VideoLAN team
00012  * $Id: mtime.h 11664 2005-07-09 06:17:09Z courmisch $
00013  *
00014  * Authors: Vincent Seguin <[email protected]>
00015  *
00016  * This program is free software; you can redistribute it and/or modify
00017  * it under the terms of the GNU General Public License as published by
00018  * the Free Software Foundation; either version 2 of the License, or
00019  * (at your option) any later version.
00020  * 
00021  * This program is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00029  *****************************************************************************/
00030 
00031 /*****************************************************************************
00032  * LAST_MDATE: date which will never happen
00033  *****************************************************************************
00034  * This date can be used as a 'never' date, to mark missing events in a function
00035  * supposed to return a date, such as nothing to display in a function
00036  * returning the date of the first image to be displayed. It can be used in
00037  * comparaison with other values: all existing dates will be earlier.
00038  *****************************************************************************/
00039 #define LAST_MDATE ((mtime_t)((uint64_t)(-1)/2))
00040 
00041 /*****************************************************************************
00042  * MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
00043  *****************************************************************************
00044  * This values is the maximal possible size of the string returned by the
00045  * mstrtime() function, including '-' and the final '\0'. It should be used to
00046  * allocate the buffer.
00047  *****************************************************************************/
00048 #define MSTRTIME_MAX_SIZE 22
00049 
00050 /* Well, Duh? But it does clue us in that we are converting from
00051    millisecond quantity to a second quantity or vice versa.
00052 */
00053 #define MILLISECONDS_PER_SEC 1000
00054 
00055 #define msecstotimestr(psz_buffer, msecs) \
00056   secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) )
00057 
00058 /*****************************************************************************
00059  * Prototypes
00060  *****************************************************************************/
00061 VLC_EXPORT( char *,  mstrtime, ( char *psz_buffer, mtime_t date ) );
00062 VLC_EXPORT( mtime_t, mdate,    ( void ) );
00063 VLC_EXPORT( void,    mwait,    ( mtime_t date ) );
00064 VLC_EXPORT( void,    msleep,   ( mtime_t delay ) );
00065 VLC_EXPORT( char *,  secstotimestr, ( char *psz_buffer, int secs ) );
00066 
00067 /*****************************************************************************
00068  * date_t: date incrementation without long-term rounding errors
00069  *****************************************************************************/
00070 struct date_t
00071 {
00072     mtime_t  date;
00073     uint32_t i_divider_num;
00074     uint32_t i_divider_den;
00075     uint32_t i_remainder;
00076 };
00077 
00078 VLC_EXPORT( void,    date_Init,      ( date_t *, uint32_t, uint32_t ) );
00079 VLC_EXPORT( void,    date_Change,    ( date_t *, uint32_t, uint32_t ) );
00080 VLC_EXPORT( void,    date_Set,       ( date_t *, mtime_t ) );
00081 VLC_EXPORT( mtime_t, date_Get,       ( const date_t * ) );
00082 VLC_EXPORT( void,    date_Move,      ( date_t *, mtime_t ) );
00083 VLC_EXPORT( mtime_t, date_Increment, ( date_t *, uint32_t ) );

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2