root/trunk/libffado/src/libutil/TimeSource.h

Revision 445, 2.4 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef __FFADO_TIMESOURCE__
25 #define __FFADO_TIMESOURCE__
26
27 #include "../debugmodule/debugmodule.h"
28
29 #include <vector>
30
31 typedef uint64_t ffado_microsecs_t;
32
33 namespace Util {
34
35 class TimeSource;
36 typedef std::vector<TimeSource *> TimeSourceVector;
37 typedef std::vector<TimeSource *>::iterator TimeSourceVectorIterator;
38
39 /*!
40 \brief The base class for all TimeSource's.
41
42     Any object that can act as a source of timing
43     information should subclass this class and implement
44     its virtual functions.
45
46     A TimeSource can be slaved to another TimeSource, allowing
47     the mapping of the master's time to the slave's time.
48 */
49 class TimeSource {
50
51 public:
52
53     TimeSource();
54     virtual ~TimeSource();
55
56     virtual ffado_microsecs_t getCurrentTime()=0;
57     virtual ffado_microsecs_t getCurrentTimeAsUsecs()=0;
58     virtual ffado_microsecs_t unWrapTime(ffado_microsecs_t t)=0;
59     virtual ffado_microsecs_t wrapTime(ffado_microsecs_t t)=0;
60
61     ffado_microsecs_t mapMasterTime(ffado_microsecs_t t);
62
63     bool updateTimeSource();
64
65     bool registerSlave(TimeSource *ts);
66     bool unregisterSlave(TimeSource *ts);
67
68     virtual void setVerboseLevel(int l);
69
70     virtual void printTimeSourceInfo();
71
72 protected:
73
74 private:
75     bool setMaster(TimeSource *ts);
76     void clearMaster();
77
78     void initSlaveTimeSource();
79
80     TimeSource * m_Master;
81     TimeSourceVector m_Slaves;
82
83     ffado_microsecs_t m_last_master_time;
84     ffado_microsecs_t m_last_time;
85
86     double m_slave_rate;
87     int64_t m_slave_offset;
88     double m_last_err;
89
90     DECLARE_DEBUG_MODULE;
91
92 };
93
94 } // end of namespace Util
95
96 #endif /* __FFADO_TIMESOURCE__ */
97
98
Note: See TracBrowser for help on using the browser.