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