1 /*
2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2004-2008 Grame
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14 
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 
21 #include "JackTime.h"
22 #include "JackError.h"
23 #include "JackTypes.h"
24 #include <mach/mach_time.h>
25 #include <unistd.h>
26 
27 static double __jack_time_ratio;
28 
JackSleep(long usec)29 SERVER_EXPORT void JackSleep(long usec)
30 {
31 	usleep(usec);
32 }
33 
34 /* This should only be called ONCE per process. */
InitTime()35 SERVER_EXPORT void InitTime()
36 {
37 	mach_timebase_info_data_t info;
38 	mach_timebase_info(&info);
39 	__jack_time_ratio = ((double)info.numer / (double)info.denom) / 1000;
40 }
41 
EndTime()42 SERVER_EXPORT void EndTime()
43 {}
44 
GetMicroSeconds(void)45 SERVER_EXPORT jack_time_t GetMicroSeconds(void)
46 {
47     return (jack_time_t) (mach_absolute_time() * __jack_time_ratio);
48 }
49 
SetClockSource(jack_timer_type_t source)50 void SetClockSource(jack_timer_type_t source)
51 {}
52 
ClockSourceName(jack_timer_type_t source)53 const char* ClockSourceName(jack_timer_type_t source)
54 {
55     return "";
56 }
57