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 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.
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.
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.
21 #ifndef __JackClient__
22 #define __JackClient__
24 #include "JackClientInterface.h"
25 #include "JackThread.h"
26 #include "JackConstants.h"
27 #include "JackSynchro.h"
28 #include "JackPlatformPlug.h"
29 #include "JackChannel.h"
37 class JackGraphManager
;
40 struct JackClientControl
;
41 struct JackEngineControl
;
44 \brief The base class for clients: share part of the implementation for JackInternalClient and JackLibClient.
47 class JackClient
: public JackClientInterface
, public JackRunnableInterface
49 friend class JackDebugClient
;
53 JackProcessCallback fProcess
;
54 JackGraphOrderCallback fGraphOrder
;
55 JackXRunCallback fXrun
;
56 JackShutdownCallback fShutdown
;
57 JackInfoShutdownCallback fInfoShutdown
;
58 JackThreadInitCallback fInit
;
59 JackBufferSizeCallback fBufferSize
;
60 JackSampleRateCallback fSampleRate
;
61 JackClientRegistrationCallback fClientRegistration
;
62 JackFreewheelCallback fFreewheel
;
63 JackPortRegistrationCallback fPortRegistration
;
64 JackPortConnectCallback fPortConnect
;
65 JackPortRenameCallback fPortRename
;
66 JackTimebaseCallback fTimebase
;
67 JackSyncCallback fSync
;
68 JackThreadCallback fThreadFun
;
74 void* fInfoShutdownArg
;
78 void* fClientRegistrationArg
;
80 void* fPortRegistrationArg
;
81 void* fPortConnectArg
;
88 JackThread fThread
; /*! Thread to execute the Process function */
89 detail::JackClientChannelInterface
* fChannel
;
90 JackSynchro
* fSynchroTable
;
91 std::list
<jack_port_id_t
> fPortList
;
94 void SetupDriverSync(bool freewheel
);
97 void CallSyncCallback();
98 void CallTimebaseCallback();
100 virtual int ClientNotifyImp(int refnum
, const char* name
, int notify
, int sync
, const char* message
, int value1
, int value
);
102 inline void DummyCycle();
103 inline void ExecuteThread();
104 inline bool WaitSync();
105 inline void SignalSync();
106 inline int CallProcessCallback();
109 inline jack_nframes_t
CycleWaitAux();
110 inline void CycleSignalAux(int status
);
111 inline void CallSyncCallbackAux();
112 inline void CallTimebaseCallbackAux();
113 inline int ActivateAux();
118 JackClient(JackSynchro
* table
);
119 virtual ~JackClient();
121 virtual int Open(const char* server_name
, const char* name
, jack_options_t options
, jack_status_t
* status
) = 0;
124 virtual JackGraphManager
* GetGraphManager() const = 0;
125 virtual JackEngineControl
* GetEngineControl() const = 0;
128 virtual int ClientNotify(int refnum
, const char* name
, int notify
, int sync
, const char* message
, int value1
, int value2
);
130 virtual int Activate();
131 virtual int Deactivate();
134 virtual int SetBufferSize(jack_nframes_t buffer_size
);
135 virtual int SetFreeWheel(int onoff
);
136 virtual void ShutDown();
137 virtual pthread_t
GetThreadID();
140 virtual int PortRegister(const char* port_name
, const char* port_type
, unsigned long flags
, unsigned long buffer_size
);
141 virtual int PortUnRegister(jack_port_id_t port
);
143 virtual int PortConnect(const char* src
, const char* dst
);
144 virtual int PortDisconnect(const char* src
, const char* dst
);
145 virtual int PortDisconnect(jack_port_id_t src
);
147 virtual int PortIsMine(jack_port_id_t port_index
);
148 virtual int PortRename(jack_port_id_t port_index
, const char* name
);
151 virtual int ReleaseTimebase();
152 virtual int SetSyncCallback(JackSyncCallback sync_callback
, void* arg
);
153 virtual int SetSyncTimeout(jack_time_t timeout
);
154 virtual int SetTimebaseCallback(int conditional
, JackTimebaseCallback timebase_callback
, void* arg
);
155 virtual void TransportLocate(jack_nframes_t frame
);
156 virtual jack_transport_state_t
TransportQuery(jack_position_t
* pos
);
157 virtual jack_nframes_t
GetCurrentTransportFrame();
158 virtual int TransportReposition(jack_position_t
* pos
);
159 virtual void TransportStart();
160 virtual void TransportStop();
163 virtual void OnShutdown(JackShutdownCallback callback
, void *arg
);
164 virtual void OnInfoShutdown(JackInfoShutdownCallback callback
, void *arg
);
165 virtual int SetProcessCallback(JackProcessCallback callback
, void* arg
);
166 virtual int SetXRunCallback(JackXRunCallback callback
, void* arg
);
167 virtual int SetInitCallback(JackThreadInitCallback callback
, void* arg
);
168 virtual int SetGraphOrderCallback(JackGraphOrderCallback callback
, void* arg
);
169 virtual int SetBufferSizeCallback(JackBufferSizeCallback callback
, void* arg
);
170 virtual int SetSampleRateCallback(JackBufferSizeCallback callback
, void* arg
);
171 virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback
, void* arg
);
172 virtual int SetFreewheelCallback(JackFreewheelCallback callback
, void* arg
);
173 virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback
, void* arg
);
174 virtual int SetPortConnectCallback(JackPortConnectCallback callback
, void *arg
);
175 virtual int SetPortRenameCallback(JackPortRenameCallback callback
, void *arg
);
178 virtual char* GetInternalClientName(int ref
);
179 virtual int InternalClientHandle(const char* client_name
, jack_status_t
* status
);
180 virtual int InternalClientLoad(const char* client_name
, jack_options_t options
, jack_status_t
* status
, jack_varargs_t
* va
);
181 virtual void InternalClientUnload(int ref
, jack_status_t
* status
);
183 jack_nframes_t
CycleWait();
184 void CycleSignal(int status
);
185 int SetProcessThread(JackThreadCallback fun
, void *arg
);
187 // JackRunnableInterface interface
192 } // end of namespace