vlc_mtime.h

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

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1