1 module pulse.timeval;
2 
3 import core.sys.posix.sys.select;
4 
5 import pulse.sample;
6 
7 extern (C):
8 
9 /***
10   This file is part of PulseAudio.
11 
12   Copyright 2004-2006 Lennart Poettering
13   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
14 
15   PulseAudio is free software; you can redistribute it and/or modify
16   it under the terms of the GNU Lesser General Public License as
17   published by the Free Software Foundation; either version 2.1 of the
18   License, or (at your option) any later version.
19 
20   PulseAudio is distributed in the hope that it will be useful, but
21   WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23   Lesser General Public License for more details.
24 
25   You should have received a copy of the GNU Lesser General Public
26   License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
27 ***/
28 
29 /** \file
30  * Utility functions for handling timeval calculations */
31 
32 /** The number of milliseconds in a second */
33 enum PA_MSEC_PER_SEC = cast(pa_usec_t) 1000;
34 
35 /** The number of microseconds in a second */
36 enum PA_USEC_PER_SEC = cast(pa_usec_t) 1000000;
37 
38 /** The number of nanoseconds in a second */
39 enum PA_NSEC_PER_SEC = cast(ulong) 1000000000;
40 
41 /** The number of microseconds in a millisecond */
42 enum PA_USEC_PER_MSEC = cast(pa_usec_t) 1000;
43 
44 /** The number of nanoseconds in a millisecond */
45 enum PA_NSEC_PER_MSEC = cast(ulong) 1000000;
46 
47 /** The number of nanoseconds in a microsecond */
48 enum PA_NSEC_PER_USEC = cast(ulong) 1000;
49 
50 /** Invalid time in usec. \since 0.9.15 */
51 enum PA_USEC_INVALID = cast(pa_usec_t) -1;
52 
53 /** Biggest time in usec. \since 0.9.18 */
54 enum PA_USEC_MAX = cast(pa_usec_t) -2;
55 
56 /** Return the current wallclock timestamp, just like UNIX gettimeofday(). */
57 timeval* pa_gettimeofday (timeval* tv);
58 
59 /** Calculate the difference between the two specified timeval
60  * structs. */
61 pa_usec_t pa_timeval_diff (const(timeval)* a, const(timeval)* b);
62 
63 /** Compare the two timeval structs and return 0 when equal, negative when a < b, positive otherwise */
64 int pa_timeval_cmp (const(timeval)* a, const(timeval)* b);
65 
66 /** Return the time difference between now and the specified timestamp */
67 pa_usec_t pa_timeval_age (const(timeval)* tv);
68 
69 /** Add the specified time in microseconds to the specified timeval structure */
70 timeval* pa_timeval_add (timeval* tv, pa_usec_t v);
71 
72 /** Subtract the specified time in microseconds to the specified timeval structure. \since 0.9.11 */
73 timeval* pa_timeval_sub (timeval* tv, pa_usec_t v);
74 
75 /** Store the specified usec value in the timeval struct. \since 0.9.7 */
76 timeval* pa_timeval_store (timeval* tv, pa_usec_t v);
77 
78 /** Load the specified tv value and return it in usec. \since 0.9.7 */
79 pa_usec_t pa_timeval_load (const(timeval)* tv);
80