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

Revision 864, 2.4 kB (checked in by ppalmers, 16 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

Line 
1 /*
2  * Copyright (C) 2005-2008 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 program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
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.