vlc/include/vlc_mtime.h

86 lines
4.3 KiB
C
Raw Normal View History

/*****************************************************************************
* vlc_mtime.h: high resolution time management functions
*****************************************************************************
1999-08-08 14:42:54 +02:00
* This header provides portable high precision time management functions,
* which should be the only ones used in other segments of the program, since
* functions like gettimeofday() and ftime() are not always supported.
* Most functions are declared as inline or as macros since they are only
* interfaces to system calls and have to be called frequently.
* 'm' stands for 'micro', since maximum resolution is the microsecond.
* Functions prototyped are implemented in interface/mtime.c.
*****************************************************************************
2005-07-09 08:17:09 +02:00
* Copyright (C) 1996, 1997, 1998, 1999, 2000 the VideoLAN team
* $Id$
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2006-01-13 00:10:04 +01:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
1999-08-08 14:42:54 +02:00
* LAST_MDATE: date which will never happen
*****************************************************************************
1999-08-08 14:42:54 +02:00
* This date can be used as a 'never' date, to mark missing events in a function
* supposed to return a date, such as nothing to display in a function
* returning the date of the first image to be displayed. It can be used in
* comparaison with other values: all existing dates will be earlier.
*****************************************************************************/
#define LAST_MDATE ((mtime_t)((uint64_t)(-1)/2))
1999-08-08 14:42:54 +02:00
/*****************************************************************************
1999-08-08 14:42:54 +02:00
* MSTRTIME_MAX_SIZE: maximum possible size of mstrtime
*****************************************************************************
1999-08-08 14:42:54 +02:00
* This values is the maximal possible size of the string returned by the
* mstrtime() function, including '-' and the final '\0'. It should be used to
* allocate the buffer.
*****************************************************************************/
#define MSTRTIME_MAX_SIZE 22
1999-08-08 14:42:54 +02:00
/* Well, Duh? But it does clue us in that we are converting from
millisecond quantity to a second quantity or vice versa.
*/
#define MILLISECONDS_PER_SEC 1000
#define msecstotimestr(psz_buffer, msecs) \
secstotimestr( psz_buffer, (msecs / (int) MILLISECONDS_PER_SEC) )
/*****************************************************************************
1999-08-08 14:42:54 +02:00
* Prototypes
*****************************************************************************/
VLC_EXPORT( char *, mstrtime, ( char *psz_buffer, mtime_t date ) );
VLC_EXPORT( mtime_t, mdate, ( void ) );
VLC_EXPORT( void, mwait, ( mtime_t date ) );
VLC_EXPORT( void, msleep, ( mtime_t delay ) );
VLC_EXPORT( char *, secstotimestr, ( char *psz_buffer, int secs ) );
Some heavy changes today: * Removed duplicate function checks from configure.in. * Added extra magic to Makefile.modules so that the module Makefiles are now ridiculously simple. And I mean *simple*. Check it! This will make a possible switch to full autoconf/automake a lot easier. * Added the vlc version name to the plugin symbols, to be sure we only load plugins with the same version number. A nasty consequence is that you need to rebuild your tree after midnight if you are using a CVS tree :-) * Got rid of modules_export.h by #defining exported functions in the same header as their prototype. * Added modules_inner.h and other commonly used .h files to common.h so there are less and less files to include, and renamed common.h to <videolan/vlc.h>. * First modifications to the module handling system towards my ultimate goal to get rid of the *_Probe functions. Got rid of TestMethod and TestCPU, as well as src/misc/tests.c. * Wrote the chroma plugin handling functions. No YUV functions have been ported yet because it'ls a lot of work, but the core system works, I tried it with a naive yv12->rgb16 plugin (which will disappear when the real functions are ready). * Made a lot of functions in dvd_summary.c one-liners to avoid wasting too many output lines. * Fixed a segfault in input_dvd.c:DVDInit. * Added a fixfiles.sh script in plugins/gtk to be run after Glade has generated its C files. * Did some work on the KDE interface to make it suck a bit less. It still segfaults, but at least it runs and it looks less ugly. * RGB SDL rendering works again, though in 16bpp only. * Made plugins/vcd/linux_cdrom_tools.c independent of any vlc structure so that it'll be easily put in a library. Maybe libdvdcss? * Fixed VCD date display. * Merged vout_xvideo.c, vout_x11.c and vout_common.c into xcommon.c. * Wrote non-Shm XVideo output. * Made X11 output work again. Still pretty unstable, only works for 16bpp. * Additional french translation in po/fr.po. Any taker for the rest? * Fixed a segfault in video_output.c when the allocated pictures were not direct buffers. * If $DISPLAY isn't set, don't try to run the Gtk+ interface. * Replaced 48x48 .xpm images with 32x32 ones to conform to Debian policy (Closes Debian bug #126939). * Removed the automatic ./configure launch when running `make all' for the first time. Stuff currently more broken than it ought to be: * The wall filter. Being fixed. * x11 and sdl plugins for depth != 16bpp. * Software YUV. * gvlc, gnome-vlc, kvlc shortcuts. Use --intf instead for the moment.
2001-12-30 08:09:56 +01:00
/*****************************************************************************
* date_t: date incrementation without long-term rounding errors
*****************************************************************************/
struct date_t
{
mtime_t date;
uint32_t i_divider_num;
uint32_t i_divider_den;
uint32_t i_remainder;
};
VLC_EXPORT( void, date_Init, ( date_t *, uint32_t, uint32_t ) );
VLC_EXPORT( void, date_Change, ( date_t *, uint32_t, uint32_t ) );
VLC_EXPORT( void, date_Set, ( date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, date_Get, ( const date_t * ) );
VLC_EXPORT( void, date_Move, ( date_t *, mtime_t ) );
VLC_EXPORT( mtime_t, date_Increment, ( date_t *, uint32_t ) );
2007-02-09 19:24:06 +01:00
VLC_EXPORT( uint64_t, NTPtime64, ( void ) );