root/branches/streaming-rework/src/libutil/Time.h

Revision 384, 2.0 kB (checked in by pieterpalmers, 17 years ago)

- temporary commit as backup measure
- rewrote synchronisation code
- receive streaming based on SYT works
- transmit streaming synced to received stream sort of works, still

have to iron out some issues.

NOTE: all devices but the bebob's are disabled in this code,

because they still have to be ported to the new sync
mechanism.

Line 
1 /*
2 Time.h
3 FreeBob Streaming API
4 FreeBob = Firewire (pro-)audio for linux
5
6 http://freebob.sf.net
7
8 Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>
9        
10 Based upon JackTime.h from the jackdmp package.
11 Original Copyright:
12
13 Copyright (C) 2001-2003 Paul Davis
14 Copyright (C) 2004-2006 Grame
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU Lesser General Public License as published by
18 the Free Software Foundation; either version 2.1 of the License, or
19 (at your option) any later version.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 GNU Lesser General Public License for more details.
25
26 You should have received a copy of the GNU Lesser General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
30 */
31
32 #ifndef __Time__
33 #define __Time__
34
35 #include <stdio.h>
36 #include <inttypes.h>
37
38 // #define GETCYCLE_TIME
39
40 /**
41  * Type used to represent the value of free running
42  * monotonic clock with units of microseconds.
43  */
44
45 typedef uint64_t freebob_microsecs_t;
46
47
48 #ifdef __cplusplus
49 extern "C"
50 {
51 #endif
52
53
54 #include <unistd.h>
55
56     static inline void FreebobSleep(long usec) {
57         usleep(usec);
58     }
59
60 #ifdef GETCYCLE_TIME
61         #include "cycles.h"
62     extern freebob_microsecs_t __freebob_cpu_mhz;
63     extern freebob_microsecs_t GetMhz();
64     extern void InitTime();
65     static inline freebob_microsecs_t GetMicroSeconds (void) {
66         return get_cycles() / __freebob_cpu_mhz;
67     }
68 #else
69         #include <time.h>
70     extern void InitTime();
71     static inline freebob_microsecs_t GetMicroSeconds (void) {
72         struct timespec ts;
73         clock_gettime(CLOCK_MONOTONIC, &ts);
74         return (freebob_microsecs_t)ts.tv_sec * 1000000LL + ts.tv_nsec / 1000;
75     }
76 #endif
77
78
79 #ifdef __cplusplus
80 }
81 #endif
82
83
84 #endif
85
86
87
Note: See TracBrowser for help on using the browser.