2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackDriver__
22 #define __JackDriver__
25 #include "JackClientInterface.h"
26 #include "JackConstants.h"
27 #include "JackPlatformPlug.h"
28 #include "JackClientControl.h"
34 class JackLockedEngine
;
35 class JackGraphManager
;
36 struct JackEngineControl
;
39 \brief The base interface for drivers.
42 class SERVER_EXPORT JackDriverInterface
49 virtual ~JackDriverInterface()
52 virtual int Open() = 0;
54 virtual int Open (bool capturing
,
59 const char* capture_driver_name
,
60 const char* playback_driver_name
,
61 jack_nframes_t capture_latency
,
62 jack_nframes_t playback_latency
) = 0;
64 virtual int Open(jack_nframes_t buffer_size
,
65 jack_nframes_t samplerate
,
71 const char* capture_driver_name
,
72 const char* playback_driver_name
,
73 jack_nframes_t capture_latency
,
74 jack_nframes_t playback_latency
) = 0;
76 virtual int Attach() = 0;
77 virtual int Detach() = 0;
79 virtual int Read() = 0;
80 virtual int Write() = 0;
82 virtual int Start() = 0;
83 virtual int Stop() = 0;
85 virtual bool IsFixedBufferSize() = 0;
86 virtual int SetBufferSize(jack_nframes_t buffer_size
) = 0;
87 virtual int SetSampleRate(jack_nframes_t sample_rate
) = 0;
89 virtual int Process() = 0;
90 virtual int ProcessNull() = 0;
92 virtual void SetMaster(bool onoff
) = 0;
93 virtual bool GetMaster() = 0;
94 virtual void AddSlave(JackDriverInterface
* slave
) = 0;
95 virtual void RemoveSlave(JackDriverInterface
* slave
) = 0;
96 virtual std::list
<JackDriverInterface
*> GetSlaves() = 0;
97 virtual int ProcessSlaves() = 0;
99 virtual bool IsRealTime() const = 0;
103 \brief The base interface for drivers clients.
106 class SERVER_EXPORT JackDriverClientInterface
: public JackDriverInterface
, public JackClientInterface
110 \brief The base class for drivers.
113 class SERVER_EXPORT JackDriver
: public JackDriverClientInterface
118 char fCaptureDriverName
[JACK_CLIENT_NAME_SIZE
+ 1];
119 char fPlaybackDriverName
[JACK_CLIENT_NAME_SIZE
+ 1];
120 char fAliasName
[JACK_CLIENT_NAME_SIZE
+ 1];
121 jack_nframes_t fCaptureLatency
;
122 jack_nframes_t fPlaybackLatency
;
123 jack_time_t fBeginDateUst
;
124 jack_time_t fEndDateUst
;
126 JackLockedEngine
* fEngine
;
127 JackGraphManager
* fGraphManager
;
128 JackSynchro
* fSynchroTable
;
129 JackEngineControl
* fEngineControl
;
130 JackClientControl fClientControl
;
131 std::list
<JackDriverInterface
*> fSlaveList
;
135 void CycleTakeBeginTime();
136 void CycleTakeEndTime();
138 void SetupDriverSync(int ref
, bool freewheel
);
140 void NotifyXRun(jack_time_t callback_usecs
, float delayed_usecs
); // XRun notification sent by the driver
141 void NotifyBufferSize(jack_nframes_t buffer_size
); // BufferSize notification sent by the driver
142 void NotifySampleRate(jack_nframes_t sample_rate
); // SampleRate notification sent by the driver
146 JackDriver(const char* name
, const char* alias
, JackLockedEngine
* engine
, JackSynchro
* table
);
148 virtual ~JackDriver();
150 void SetMaster(bool onoff
);
153 void AddSlave(JackDriverInterface
* slave
);
154 void RemoveSlave(JackDriverInterface
* slave
);
155 std::list
<JackDriverInterface
*> GetSlaves()
163 virtual int Open (bool capturing
,
168 const char* capture_driver_name
,
169 const char* playback_driver_name
,
170 jack_nframes_t capture_latency
,
171 jack_nframes_t playback_latency
);
173 virtual int Open(jack_nframes_t buffer_size
,
174 jack_nframes_t samplerate
,
180 const char* capture_driver_name
,
181 const char* playback_driver_name
,
182 jack_nframes_t capture_latency
,
183 jack_nframes_t playback_latency
);
186 virtual int Process();
187 virtual int ProcessNull();
189 virtual int Attach();
190 virtual int Detach();
198 virtual bool IsFixedBufferSize();
199 virtual int SetBufferSize(jack_nframes_t buffer_size
);
200 virtual int SetSampleRate(jack_nframes_t sample_rate
);
202 virtual int ClientNotify(int refnum
, const char* name
, int notify
, int sync
, int value1
, int value2
);
203 virtual JackClientControl
* GetClientControl() const;
205 virtual bool IsRealTime() const;
206 virtual bool Initialize(); // To be called by the wrapping thread Init method when the driver is a "blocking" one
210 } // end of namespace