2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2005 Jussi Laako
4 Copyright (C) 2004-2008 Grame
5 Copyright (C) 2018 Greg V
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "JackConstants.h"
25 #include "JackTypes.h"
26 #include "JackError.h"
31 jack_time_t (*_jack_get_microseconds
)(void) = 0;
33 static jack_time_t
jack_get_microseconds_from_system (void)
38 clock_gettime(CLOCK_MONOTONIC
, &time
);
39 jackTime
= (jack_time_t
) time
.tv_sec
* 1e6
+
40 (jack_time_t
) time
.tv_nsec
/ 1e3
;
45 SERVER_EXPORT
void JackSleep(long usec
)
50 SERVER_EXPORT
void InitTime()
52 /* nothing to do on a generic system - we use the system clock */
55 SERVER_EXPORT
void EndTime()
58 void SetClockSource(jack_timer_type_t source
)
60 jack_log("Clock source : %s", ClockSourceName(source
));
64 case JACK_TIMER_SYSTEM_CLOCK
:
66 _jack_get_microseconds
= jack_get_microseconds_from_system
;
71 const char* ClockSourceName(jack_timer_type_t source
)
74 case JACK_TIMER_SYSTEM_CLOCK
:
75 return "system clock via clock_gettime";
81 SERVER_EXPORT jack_time_t
GetMicroSeconds()
83 return _jack_get_microseconds();
86 SERVER_EXPORT jack_time_t
jack_get_microseconds()
88 return _jack_get_microseconds();