vlc/include/vlc_tick.h

315 lines
10 KiB
C
Raw Normal View History

/*****************************************************************************
* vlc_tick.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.
*****************************************************************************
LGPL Re-license almost all of libVLC and libVLCcore to LGPLv2.1+ This move was authorized by the developers, either: - by e-mail, - by vote at the VideoLAN Dev Days 2011, - on the license website, - in a contract, oral or written. No objection was raised, so far. The developers agreeing are: Justus Piater Alexis Ballier Alexander Bethke Mohammed Adnène Trojette Alex Converse Alexey Sokolov Alexis de Lattre Andre Pang Anthony Loiseau Cyril Deguet André Weber Boris Dorès Brieuc Jeunhomme Benjamin Drung Hugo Beauzée-Luyssen Benoit Steiner Benjamin Pracht Bernie Purcell Przemyslaw Fiala Arnaud de Bossoreille de Ribou Brad Smith Nick Briggs Christopher Rath Christophe Courtaut Christopher Mueller Clement Chesnin Andres Krapf Damien Fouilleul David Flynn Sebastien Zwickert Antoine Cellerier Jérôme Decoodt Jérome Decoodt Dylan Yudaken Eduard Babayan Eugenio Jarosiewicz Elliot Murphy Eric Petit Erwan Tulou Etienne Membrives Ludovic Fauvet Fabio Ritrovato Tobias Güntner Jakub Wieczorek Frédéric Crozat Francois Cartegnie Laurent Aimar Florian G. Pflug Felix Paul Kühne Frank Enderle Rafaël Carré Simon Latapie Gildas Bazin Geoffroy Couprie Julien / Gellule Gildas Bazin Arnaud Schauly Toralf Niebuhr Vicente Jimenez Aguilar Derk-Jan Hartman Henri Fallon Ilkka Ollakka Olivier Teulière Rémi Duraffort Jakob Leben Jean-Baptiste Kempf Jean-Paul Saman Jean-Philippe Grimaldi Jean-François Massol Gaël Hendryckx Jakob Leben Jean-Marc Dressler Jai Menon Johan Bilien Johann Ransay Joris van Rooij JP Dinger Jean-Philippe André Adrien Grand Juha Jeronen Juho Vähä-Herttua Kaarlo Raiha Kaarlo Raiha Kamil Baldyga Keary Griffin Ken Self KO Myung-Hun Pierre Ynard Filippo Carone Loïc Minier Luca Barbato Lucas C. Villa Real Lukas Durfina Adrien Maglo Marc Ariberti Mark Lee Mark Moriarty Martin Storsjö Christophe Massiot Michel Kaempf Marian Ďurkovič Mirsal Ennaime Carlo Calabrò Damien Lucas Naohiro Koriyama Basos G Pierre Baillet Vincent Penquerc'h Olivier Aubert Pankaj Yadav Paul Corke Pierre d'Herbemont Philippe Morin Antoine Lejeune Michael Ploujnikov Jean-Marc Dressler Michael Hanselmann Rafaël Carré Ramiro Polla Rémi Denis-Courmont Renaud Dartus Richard Shepherd Faustino Osuna Arnaud Vallat Rob Jonson Robert Jedrzejczyk Steve Lhomme Rocky Bernstein Romain Goyet Rov Juvano Sam Hocevar Martin T. H. Sandsmark Sebastian Birk Sébastien Escudier Vincent Seguin Fabio Ritrovato Sigmund Augdal Helberg Casian Andrei Srikanth Raju Hannes Domani Stéphane Borel Stephan Krempel Stephan Assmus Tony Castley Pavlov Konstantin Eric Petit Tanguy Krotoff Dennis van Amerongen Michel Lespinasse Can Wu Xavier Marchesini Sébastien Toque Christophe Mutricy Yoann Peronneau Yohann Martineau Yuval Tze Scott Caudle Clément Stenac It is possible, that some minor piece of code was badly tracked, for some reasons (SVN, mainly) or that some small developers did not answer. However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3", and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and the very vast majority of developers have agreed (> 99.99% of the code, > 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
* Copyright (C) 1996, 1997, 1998, 1999, 2000 VLC authors and VideoLAN
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
LGPL Re-license almost all of libVLC and libVLCcore to LGPLv2.1+ This move was authorized by the developers, either: - by e-mail, - by vote at the VideoLAN Dev Days 2011, - on the license website, - in a contract, oral or written. No objection was raised, so far. The developers agreeing are: Justus Piater Alexis Ballier Alexander Bethke Mohammed Adnène Trojette Alex Converse Alexey Sokolov Alexis de Lattre Andre Pang Anthony Loiseau Cyril Deguet André Weber Boris Dorès Brieuc Jeunhomme Benjamin Drung Hugo Beauzée-Luyssen Benoit Steiner Benjamin Pracht Bernie Purcell Przemyslaw Fiala Arnaud de Bossoreille de Ribou Brad Smith Nick Briggs Christopher Rath Christophe Courtaut Christopher Mueller Clement Chesnin Andres Krapf Damien Fouilleul David Flynn Sebastien Zwickert Antoine Cellerier Jérôme Decoodt Jérome Decoodt Dylan Yudaken Eduard Babayan Eugenio Jarosiewicz Elliot Murphy Eric Petit Erwan Tulou Etienne Membrives Ludovic Fauvet Fabio Ritrovato Tobias Güntner Jakub Wieczorek Frédéric Crozat Francois Cartegnie Laurent Aimar Florian G. Pflug Felix Paul Kühne Frank Enderle Rafaël Carré Simon Latapie Gildas Bazin Geoffroy Couprie Julien / Gellule Gildas Bazin Arnaud Schauly Toralf Niebuhr Vicente Jimenez Aguilar Derk-Jan Hartman Henri Fallon Ilkka Ollakka Olivier Teulière Rémi Duraffort Jakob Leben Jean-Baptiste Kempf Jean-Paul Saman Jean-Philippe Grimaldi Jean-François Massol Gaël Hendryckx Jakob Leben Jean-Marc Dressler Jai Menon Johan Bilien Johann Ransay Joris van Rooij JP Dinger Jean-Philippe André Adrien Grand Juha Jeronen Juho Vähä-Herttua Kaarlo Raiha Kaarlo Raiha Kamil Baldyga Keary Griffin Ken Self KO Myung-Hun Pierre Ynard Filippo Carone Loïc Minier Luca Barbato Lucas C. Villa Real Lukas Durfina Adrien Maglo Marc Ariberti Mark Lee Mark Moriarty Martin Storsjö Christophe Massiot Michel Kaempf Marian Ďurkovič Mirsal Ennaime Carlo Calabrò Damien Lucas Naohiro Koriyama Basos G Pierre Baillet Vincent Penquerc'h Olivier Aubert Pankaj Yadav Paul Corke Pierre d'Herbemont Philippe Morin Antoine Lejeune Michael Ploujnikov Jean-Marc Dressler Michael Hanselmann Rafaël Carré Ramiro Polla Rémi Denis-Courmont Renaud Dartus Richard Shepherd Faustino Osuna Arnaud Vallat Rob Jonson Robert Jedrzejczyk Steve Lhomme Rocky Bernstein Romain Goyet Rov Juvano Sam Hocevar Martin T. H. Sandsmark Sebastian Birk Sébastien Escudier Vincent Seguin Fabio Ritrovato Sigmund Augdal Helberg Casian Andrei Srikanth Raju Hannes Domani Stéphane Borel Stephan Krempel Stephan Assmus Tony Castley Pavlov Konstantin Eric Petit Tanguy Krotoff Dennis van Amerongen Michel Lespinasse Can Wu Xavier Marchesini Sébastien Toque Christophe Mutricy Yoann Peronneau Yohann Martineau Yuval Tze Scott Caudle Clément Stenac It is possible, that some minor piece of code was badly tracked, for some reasons (SVN, mainly) or that some small developers did not answer. However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3", and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and the very vast majority of developers have agreed (> 99.99% of the code, > 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 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
LGPL Re-license almost all of libVLC and libVLCcore to LGPLv2.1+ This move was authorized by the developers, either: - by e-mail, - by vote at the VideoLAN Dev Days 2011, - on the license website, - in a contract, oral or written. No objection was raised, so far. The developers agreeing are: Justus Piater Alexis Ballier Alexander Bethke Mohammed Adnène Trojette Alex Converse Alexey Sokolov Alexis de Lattre Andre Pang Anthony Loiseau Cyril Deguet André Weber Boris Dorès Brieuc Jeunhomme Benjamin Drung Hugo Beauzée-Luyssen Benoit Steiner Benjamin Pracht Bernie Purcell Przemyslaw Fiala Arnaud de Bossoreille de Ribou Brad Smith Nick Briggs Christopher Rath Christophe Courtaut Christopher Mueller Clement Chesnin Andres Krapf Damien Fouilleul David Flynn Sebastien Zwickert Antoine Cellerier Jérôme Decoodt Jérome Decoodt Dylan Yudaken Eduard Babayan Eugenio Jarosiewicz Elliot Murphy Eric Petit Erwan Tulou Etienne Membrives Ludovic Fauvet Fabio Ritrovato Tobias Güntner Jakub Wieczorek Frédéric Crozat Francois Cartegnie Laurent Aimar Florian G. Pflug Felix Paul Kühne Frank Enderle Rafaël Carré Simon Latapie Gildas Bazin Geoffroy Couprie Julien / Gellule Gildas Bazin Arnaud Schauly Toralf Niebuhr Vicente Jimenez Aguilar Derk-Jan Hartman Henri Fallon Ilkka Ollakka Olivier Teulière Rémi Duraffort Jakob Leben Jean-Baptiste Kempf Jean-Paul Saman Jean-Philippe Grimaldi Jean-François Massol Gaël Hendryckx Jakob Leben Jean-Marc Dressler Jai Menon Johan Bilien Johann Ransay Joris van Rooij JP Dinger Jean-Philippe André Adrien Grand Juha Jeronen Juho Vähä-Herttua Kaarlo Raiha Kaarlo Raiha Kamil Baldyga Keary Griffin Ken Self KO Myung-Hun Pierre Ynard Filippo Carone Loïc Minier Luca Barbato Lucas C. Villa Real Lukas Durfina Adrien Maglo Marc Ariberti Mark Lee Mark Moriarty Martin Storsjö Christophe Massiot Michel Kaempf Marian Ďurkovič Mirsal Ennaime Carlo Calabrò Damien Lucas Naohiro Koriyama Basos G Pierre Baillet Vincent Penquerc'h Olivier Aubert Pankaj Yadav Paul Corke Pierre d'Herbemont Philippe Morin Antoine Lejeune Michael Ploujnikov Jean-Marc Dressler Michael Hanselmann Rafaël Carré Ramiro Polla Rémi Denis-Courmont Renaud Dartus Richard Shepherd Faustino Osuna Arnaud Vallat Rob Jonson Robert Jedrzejczyk Steve Lhomme Rocky Bernstein Romain Goyet Rov Juvano Sam Hocevar Martin T. H. Sandsmark Sebastian Birk Sébastien Escudier Vincent Seguin Fabio Ritrovato Sigmund Augdal Helberg Casian Andrei Srikanth Raju Hannes Domani Stéphane Borel Stephan Krempel Stephan Assmus Tony Castley Pavlov Konstantin Eric Petit Tanguy Krotoff Dennis van Amerongen Michel Lespinasse Can Wu Xavier Marchesini Sébastien Toque Christophe Mutricy Yoann Peronneau Yohann Martineau Yuval Tze Scott Caudle Clément Stenac It is possible, that some minor piece of code was badly tracked, for some reasons (SVN, mainly) or that some small developers did not answer. However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3", and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and the very vast majority of developers have agreed (> 99.99% of the code, > 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
LGPL Re-license almost all of libVLC and libVLCcore to LGPLv2.1+ This move was authorized by the developers, either: - by e-mail, - by vote at the VideoLAN Dev Days 2011, - on the license website, - in a contract, oral or written. No objection was raised, so far. The developers agreeing are: Justus Piater Alexis Ballier Alexander Bethke Mohammed Adnène Trojette Alex Converse Alexey Sokolov Alexis de Lattre Andre Pang Anthony Loiseau Cyril Deguet André Weber Boris Dorès Brieuc Jeunhomme Benjamin Drung Hugo Beauzée-Luyssen Benoit Steiner Benjamin Pracht Bernie Purcell Przemyslaw Fiala Arnaud de Bossoreille de Ribou Brad Smith Nick Briggs Christopher Rath Christophe Courtaut Christopher Mueller Clement Chesnin Andres Krapf Damien Fouilleul David Flynn Sebastien Zwickert Antoine Cellerier Jérôme Decoodt Jérome Decoodt Dylan Yudaken Eduard Babayan Eugenio Jarosiewicz Elliot Murphy Eric Petit Erwan Tulou Etienne Membrives Ludovic Fauvet Fabio Ritrovato Tobias Güntner Jakub Wieczorek Frédéric Crozat Francois Cartegnie Laurent Aimar Florian G. Pflug Felix Paul Kühne Frank Enderle Rafaël Carré Simon Latapie Gildas Bazin Geoffroy Couprie Julien / Gellule Gildas Bazin Arnaud Schauly Toralf Niebuhr Vicente Jimenez Aguilar Derk-Jan Hartman Henri Fallon Ilkka Ollakka Olivier Teulière Rémi Duraffort Jakob Leben Jean-Baptiste Kempf Jean-Paul Saman Jean-Philippe Grimaldi Jean-François Massol Gaël Hendryckx Jakob Leben Jean-Marc Dressler Jai Menon Johan Bilien Johann Ransay Joris van Rooij JP Dinger Jean-Philippe André Adrien Grand Juha Jeronen Juho Vähä-Herttua Kaarlo Raiha Kaarlo Raiha Kamil Baldyga Keary Griffin Ken Self KO Myung-Hun Pierre Ynard Filippo Carone Loïc Minier Luca Barbato Lucas C. Villa Real Lukas Durfina Adrien Maglo Marc Ariberti Mark Lee Mark Moriarty Martin Storsjö Christophe Massiot Michel Kaempf Marian Ďurkovič Mirsal Ennaime Carlo Calabrò Damien Lucas Naohiro Koriyama Basos G Pierre Baillet Vincent Penquerc'h Olivier Aubert Pankaj Yadav Paul Corke Pierre d'Herbemont Philippe Morin Antoine Lejeune Michael Ploujnikov Jean-Marc Dressler Michael Hanselmann Rafaël Carré Ramiro Polla Rémi Denis-Courmont Renaud Dartus Richard Shepherd Faustino Osuna Arnaud Vallat Rob Jonson Robert Jedrzejczyk Steve Lhomme Rocky Bernstein Romain Goyet Rov Juvano Sam Hocevar Martin T. H. Sandsmark Sebastian Birk Sébastien Escudier Vincent Seguin Fabio Ritrovato Sigmund Augdal Helberg Casian Andrei Srikanth Raju Hannes Domani Stéphane Borel Stephan Krempel Stephan Assmus Tony Castley Pavlov Konstantin Eric Petit Tanguy Krotoff Dennis van Amerongen Michel Lespinasse Can Wu Xavier Marchesini Sébastien Toque Christophe Mutricy Yoann Peronneau Yohann Martineau Yuval Tze Scott Caudle Clément Stenac It is possible, that some minor piece of code was badly tracked, for some reasons (SVN, mainly) or that some small developers did not answer. However, as an "œuvre collective", defined as in "CPI 113-2 alinéa 3", and seeing "Cour. Cass. 17 Mai 1978", and seeing that the editor and the very vast majority of developers have agreed (> 99.99% of the code, > 99% of developers), we are fine here.
2011-11-27 21:44:15 +01:00
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
2008-09-04 21:39:04 +02:00
#ifndef __VLC_MTIME_H
# define __VLC_MTIME_H 1
struct timespec;
#include <vlc_config.h>
/**
* High precision date or time interval
*
* Store a high precision date or time interval. The maximum precision is the
* microsecond, and a 64 bits integer is used to avoid overflows (maximum
* time interval is then 292271 years, which should be long enough for any
* video). Dates are stored as microseconds since a common date (usually the
* epoch). Note that date and time intervals can be manipulated using regular
* arithmetic operators, and that no special functions are required.
*/
typedef int64_t vlc_tick_t;
#define VLC_TICK_MIN INT64_MIN
#define VLC_TICK_MAX INT64_MAX
/*
* vlc_tick_t <> seconds (sec) conversions
*/
#define VLC_TICK_FROM_SEC(sec) (CLOCK_FREQ * (sec))
#define SEC_FROM_VLC_TICK(vtk) ((vtk) / CLOCK_FREQ)
#ifdef __cplusplus
#include <type_traits>
template <typename T>
static inline auto vlc_tick_from_sec(T sec)
-> typename std::enable_if<std::is_integral<T>::value, vlc_tick_t>::type
{
return CLOCK_FREQ * sec;
}
/* seconds in floating point */
static inline vlc_tick_t vlc_tick_from_sec(double secf)
{
return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */
}
#else /* !__cplusplus */
static inline vlc_tick_t vlc_tick_from_seci(int64_t sec)
{
return CLOCK_FREQ * sec;
}
/* seconds in floating point */
static inline vlc_tick_t vlc_tick_from_secf(double secf)
{
return (vlc_tick_t)(CLOCK_FREQ * secf); /* TODO use llround ? */
}
#define vlc_tick_from_sec(sec) _Generic((sec), \
double: vlc_tick_from_secf(sec), \
float: vlc_tick_from_secf(sec), \
default: vlc_tick_from_seci(sec) )
#endif /* !__cplusplus */
/* seconds in floating point from vlc_tick_t */
static inline double secf_from_vlc_tick(vlc_tick_t vtk)
{
return (double)vtk / (double)CLOCK_FREQ;
}
static inline vlc_tick_t vlc_tick_rate_duration(float frame_rate)
{
return (vlc_tick_t)(CLOCK_FREQ / frame_rate);
}
/*
* samples<>vlc_tick_t
*/
static inline vlc_tick_t vlc_tick_from_samples(int64_t samples, unsigned samp_rate)
{
return CLOCK_FREQ * samples / samp_rate;
}
static inline int64_t samples_from_vlc_tick(vlc_tick_t t, unsigned samp_rate)
{
return t * samp_rate / CLOCK_FREQ;
}
static inline vlc_tick_t vlc_tick_from_frac(uint64_t num, uint64_t den)
{
lldiv_t d = lldiv (num, den);
return vlc_tick_from_sec( d.quot ) + vlc_tick_from_samples(d.rem, den);
}
/*
* vlc_tick_t <> milliseconds (ms) conversions
*/
#if (CLOCK_FREQ % 1000) == 0
#define VLC_TICK_FROM_MS(ms) ((CLOCK_FREQ / INT64_C(1000)) * (ms))
#define MS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000)))
#elif (1000 % CLOCK_FREQ) == 0
#define VLC_TICK_FROM_MS(ms) ((ms) / (INT64_C(1000) / CLOCK_FREQ))
#define MS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000) / CLOCK_FREQ))
#else /* rounded overflowing conversion */
#define VLC_TICK_FROM_MS(ms) (CLOCK_FREQ * (ms) / 1000)
#define MS_FROM_VLC_TICK(vtk) ((vtk) * 1000 / CLOCK_FREQ)
#endif /* CLOCK_FREQ / 1000 */
/*
* vlc_tick_t <> microseconds (us) conversions
*/
#if (CLOCK_FREQ % 1000000) == 0
#define VLC_TICK_FROM_US(us) ((CLOCK_FREQ / INT64_C(1000000)) * (us))
#define US_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(1000000)))
#elif (1000000 % CLOCK_FREQ) == 0
#define VLC_TICK_FROM_US(us) ((us) / (INT64_C(1000000) / CLOCK_FREQ))
#define US_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000) / CLOCK_FREQ))
#else /* rounded overflowing conversion */
#define VLC_TICK_FROM_US(us) (CLOCK_FREQ * (us) / INT64_C(1000000))
#define US_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000) / CLOCK_FREQ)
#endif /* CLOCK_FREQ / 1000000 */
/*
* vlc_tick_t <> nanoseconds (ns) conversions
*/
#if (CLOCK_FREQ % 1000000000) == 0
#define VLC_TICK_FROM_NS(ns) ((ns) * (CLOCK_FREQ / (INT64_C(1000000000))))
#define NS_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / (INT64_C(1000000000))))
#elif (1000000000 % CLOCK_FREQ) == 0
#define VLC_TICK_FROM_NS(ns) ((ns) / (INT64_C(1000000000) / CLOCK_FREQ))
#define NS_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(1000000000) / CLOCK_FREQ))
#else /* rounded overflowing conversion */
#define VLC_TICK_FROM_NS(ns) (CLOCK_FREQ * (ns) / INT64_C(1000000000))
#define NS_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(1000000000) / CLOCK_FREQ)
#endif /* CLOCK_FREQ / 1000000000 */
/*
* msftime_t is a time with 100ns resolutions, typically used by Microsoft
*/
typedef int64_t msftime_t;
#define MSFTIME_FROM_SEC(sec) (INT64_C(10000000) * (sec)) /* seconds in msftime_t */
#define MSFTIME_FROM_MS(sec) (INT64_C(10000) * (sec)) /* milliseconds in msftime_t */
#if (CLOCK_FREQ % 10000000) == 0
#define VLC_TICK_FROM_MSFTIME(msft) ((msft) * (CLOCK_FREQ / INT64_C(10000000))
#define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) / (CLOCK_FREQ / INT64_C(10000000))
#elif (10000000 % CLOCK_FREQ) == 0
#define VLC_TICK_FROM_MSFTIME(msft) ((msft) / (INT64_C(10000000) / CLOCK_FREQ))
#define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * (INT64_C(10000000) / CLOCK_FREQ))
#else /* rounded overflowing conversion */
#define VLC_TICK_FROM_MSFTIME(msft) (CLOCK_FREQ * (msft) / INT64_C(10000000))
#define MSFTIME_FROM_VLC_TICK(vtk) ((vtk) * INT64_C(10000000) / CLOCK_FREQ)
#endif /* CLOCK_FREQ / 10000000 */
#define vlc_tick_from_timeval(tv) \
(vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_US( (tv)->tv_usec ))
2018-07-04 10:23:28 +02:00
#define vlc_tick_from_timespec(tv) \
(vlc_tick_from_sec( (tv)->tv_sec ) + VLC_TICK_FROM_NS( (tv)->tv_nsec ))
2018-07-04 11:36:46 +02:00
/**
* Converts a VLC tick to a POSIX time specification.
*
* \param ts [out] storage space for the time specification
* \param tick VLC tick
* \return @c ts
*/
VLC_API struct timespec *vlc_tick_to_timespec(struct timespec *restrict ts,
vlc_tick_t tick);
/*****************************************************************************
* MSTRTIME_MAX_SIZE: maximum possible size of vlc_tick_to_str
*****************************************************************************
1999-08-08 14:42:54 +02:00
* This values is the maximal possible size of the string returned by the
* vlc_tick_to_str() 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
/*****************************************************************************
1999-08-08 14:42:54 +02:00
* Prototypes
*****************************************************************************/
/**
* Convert seconds to a time in the format h:mm:ss.
*
* This function is provided for any interface function which need to print a
* time string in the format h:mm:ss
* date.
* \param ticks the time to be converted
* \param psz_buffer should be a buffer at least MSTRTIME_MAX_SIZE characters
* \return psz_buffer is returned so this can be used as printf parameter.
*/
VLC_API char * vlc_tick_to_str( char *psz_buffer, vlc_tick_t ticks );
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
2018-05-02 17:55:52 +02:00
/**
* \defgroup date Timestamps, error-free
* These functions support generating timestamps without long term rounding
* errors due to sample rate conversions.
* \ingroup input
* @{
*/
/**
* Timestamps without long-term rounding errors
*/
struct date_t
{
vlc_tick_t date;
uint32_t i_divider_num;
uint32_t i_divider_den;
uint32_t i_remainder;
};
2018-05-02 17:55:52 +02:00
/**
* Initializes a date_t.
*
* \param date date to initialize [OUT]
* \param num divider (sample rate) numerator
* \param den divider (sample rate) denominator
*/
VLC_API void date_Init(date_t *restrict date, uint32_t num, uint32_t den);
/**
* Changes the rate of a date_t.
*
* \param date date to change
* \param num divider (sample rate) numerator
* \param den divider (sample rate) denominator
*/
VLC_API void date_Change(date_t *restrict date, uint32_t num, uint32_t den);
/**
* Sets the exact timestamp of a date_t.
*
* \param date date to set the timestamp into
* \param value date value
*/
static inline void date_Set(date_t *restrict date, vlc_tick_t value)
{
date->date = value;
date->i_remainder = 0;
}
2018-05-02 17:55:52 +02:00
/**
* Gets the current timestamp from a date_t.
*
* \param date date to fetch the timestamp from
* \return date value
*/
VLC_USED static inline vlc_tick_t date_Get(const date_t *restrict date)
{
return date->date;
}
2018-05-02 17:55:52 +02:00
/**
* Increments a date.
*
* Moves the date_t timestamp forward by a given number of samples.
*
* \param date date to move forward
* \param count number of samples
* \return timestamp value after incrementing
*/
VLC_API vlc_tick_t date_Increment(date_t *restrict date, uint32_t count);
2018-05-02 17:55:52 +02:00
/**
* Decrements a date.
*
* Moves the date_t timestamp backward by a given number of samples.
*
* \param date date to move backward
* \param count number of samples
* \return date value
*/
VLC_API vlc_tick_t date_Decrement(date_t *restrict date, uint32_t count);
2018-05-02 17:55:52 +02:00
/** @} */
/**
* Gets the current wallclock time as 64-bit NTP timestamp.
*
* \return NTP 64-bits timestamp in host byte order
*/
VLC_API uint64_t vlc_ntp_time( void );
2008-09-04 21:39:04 +02:00
#endif /* !__VLC_MTIME_ */