Jack2: JackClient.h Source File

Jack2 1.9.12

JackClient.h
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
4
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.
9
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.
14
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.
18
19 */
20
21 #ifndef __JackClient__
22 #define __JackClient__
23
24 #include "JackClientInterface.h"
25 #include "JackThread.h"
26 #include "JackConstants.h"
27 #include "JackSynchro.h"
28 #include "JackPlatformPlug.h"
29 #include "JackChannel.h"
30 #include "JackRequest.h"
31 #include "varargs.h"
32 #include <list>
33
34 namespace Jack
35 {
36
37 class JackGraphManager;
38 class JackServer;
39 class JackEngine;
40 struct JackClientControl;
41 struct JackEngineControl;
42
47 class SERVER_EXPORT JackClient : public JackClientInterface, public JackRunnableInterface
48 {
49 friend class JackDebugClient;
50
51 protected:
52
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;
69 JackSessionCallback fSession;
70 JackLatencyCallback fLatency;
71
72 void* fProcessArg;
73 void* fGraphOrderArg;
74 void* fXrunArg;
75 void* fShutdownArg;
76 void* fInfoShutdownArg;
77 void* fInitArg;
78 void* fBufferSizeArg;
79 void* fSampleRateArg;
80 void* fClientRegistrationArg;
81 void* fFreewheelArg;
82 void* fPortRegistrationArg;
83 void* fPortConnectArg;
84 void* fPortRenameArg;
85 void* fTimebaseArg;
86 void* fSyncArg;
87 void* fThreadFunArg;
88 void* fSessionArg;
89 void* fLatencyArg;
90 char fServerName[JACK_SERVER_NAME_SIZE+1];
91
92 JackThread fThread;
93 detail::JackClientChannelInterface* fChannel;
94 JackSynchro* fSynchroTable;
95 std::list<jack_port_id_t> fPortList;
96
97 JackSessionReply fSessionReply;
98
99 int StartThread();
100 void SetupDriverSync(bool freewheel);
101 bool IsActive();
102
103 void CallSyncCallback();
104 void CallTimebaseCallback();
105
106 virtual int ClientNotifyImp(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value);
107
108 inline void DummyCycle();
109 inline void ExecuteThread();
110 inline bool WaitSync();
111 inline void SignalSync();
112 inline int CallProcessCallback();
113 inline void End();
114 inline void Error();
115 inline jack_nframes_t CycleWaitAux();
116 inline void CycleSignalAux(int status);
117 inline void CallSyncCallbackAux();
118 inline void CallTimebaseCallbackAux();
119 inline int ActivateAux();
120 inline void InitAux();
121 inline void SetupRealTime();
122
123 int HandleLatencyCallback(int status);
124
125 public:
126
127 JackClient(JackSynchro* table);
128 virtual ~JackClient();
129
130 virtual int Open(const char* server_name, const char* name, int uuid, jack_options_t options, jack_status_t* status) = 0;
131 virtual int Close();
132
133 virtual JackGraphManager* GetGraphManager() const = 0;
134 virtual JackEngineControl* GetEngineControl() const = 0;
135
136 // Notifications
137 virtual int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
138
139 virtual int Activate();
140 virtual int Deactivate();
141
142 // Context
143 virtual int SetBufferSize(jack_nframes_t buffer_size);
144 virtual int SetFreeWheel(int onoff);
145 virtual int ComputeTotalLatencies();
146 virtual void ShutDown(jack_status_t code, const char* message);
147 virtual jack_native_thread_t GetThreadID();
148
149 // Port management
150 virtual int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
151 virtual int PortUnRegister(jack_port_id_t port);
152
153 virtual int PortConnect(const char* src, const char* dst);
154 virtual int PortDisconnect(const char* src, const char* dst);
155 virtual int PortDisconnect(jack_port_id_t src);
156
157 virtual int PortIsMine(jack_port_id_t port_index);
158 virtual int PortRename(jack_port_id_t port_index, const char* name);
159
160 // Transport
161 virtual int ReleaseTimebase();
162 virtual int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
163 virtual int SetSyncTimeout(jack_time_t timeout);
164 virtual int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
165 virtual void TransportLocate(jack_nframes_t frame);
166 virtual jack_transport_state_t TransportQuery(jack_position_t* pos);
167 virtual jack_nframes_t GetCurrentTransportFrame();
168 virtual int TransportReposition(const jack_position_t* pos);
169 virtual void TransportStart();
170 virtual void TransportStop();
171
172 // Callbacks
173 virtual void OnShutdown(JackShutdownCallback callback, void *arg);
174 virtual void OnInfoShutdown(JackInfoShutdownCallback callback, void *arg);
175 virtual int SetProcessCallback(JackProcessCallback callback, void* arg);
176 virtual int SetXRunCallback(JackXRunCallback callback, void* arg);
177 virtual int SetInitCallback(JackThreadInitCallback callback, void* arg);
178 virtual int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg);
179 virtual int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg);
180 virtual int SetSampleRateCallback(JackBufferSizeCallback callback, void* arg);
181 virtual int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg);
182 virtual int SetFreewheelCallback(JackFreewheelCallback callback, void* arg);
183 virtual int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg);
184 virtual int SetPortConnectCallback(JackPortConnectCallback callback, void *arg);
185 virtual int SetPortRenameCallback(JackPortRenameCallback callback, void *arg);
186 virtual int SetSessionCallback(JackSessionCallback callback, void *arg);
187 virtual int SetLatencyCallback(JackLatencyCallback callback, void *arg);
188
189 // Internal clients
190 virtual char* GetInternalClientName(int ref);
191 virtual int InternalClientHandle(const char* client_name, jack_status_t* status);
192 virtual int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va);
193 virtual void InternalClientUnload(int ref, jack_status_t* status);
194
195 // RT Thread
196 jack_nframes_t CycleWait();
197 void CycleSignal(int status);
198 virtual int SetProcessThread(JackThreadCallback fun, void *arg);
199
200 // Session API
201 virtual jack_session_command_t* SessionNotify(const char* target, jack_session_event_type_t type, const char* path);
202 virtual int SessionReply(jack_session_event_t* ev);
203 virtual char* GetUUIDForClientName(const char* client_name);
204 virtual char* GetClientNameByUUID(const char* uuid);
205 virtual int ReserveClientName(const char* client_name, const char* uuid);
206 virtual int ClientHasSessionCallback(const char* client_name);
207
208 // JackRunnableInterface interface
209 bool Init();
210 bool Execute();
211 };
212
213 } // end of namespace
214
215 #endif
Jack::JackPosixSemaphore
Inter process synchronization using POSIX semaphore.
Definition: JackPosixSemaphore.h:36
Jack::JackMachThread
Darwin threads. Real-time threads are actually "time constraint" threads.
Definition: JackMachThread.h:92
_jack_session_event
Definition: JackSession.h:45
Jack::JackClient::fChannel
detail::JackClientChannelInterface * fChannel
Definition: JackClient.h:93
jack_varargs_t
Definition: varargs.h:34
_jack_position
Definition: types.h:554
Jack::detail::JackClientChannelInterface
Inter process channel for server/client bidirectionnal communication : request and (receiving) notifi...
Definition: JackChannel.h:90
Jack::JackClientInterface
Client interface.
Definition: JackClientInterface.h:35
Jack::JackGraphManager
Graph manager: contains the connection manager and the port array.
Definition: JackGraphManager.h:40
Jack::JackClient
The base class for clients: share part of the implementation for JackInternalClient and JackLibClient...
Definition: JackClient.h:47
JackSessionCallback
void(* JackSessionCallback)(jack_session_event_t *event, void *arg)
Definition: session.h:162
Jack::JackEngineControl
Engine control in shared memory.
Definition: JackEngineControl.h:49
Jack::JackDebugClient
A "decorator" debug client to validate API use.
Definition: JackDebugClient.h:49
Jack::JackRunnableInterface
The base class for runnable objects, that have an Init and Execute method to be called in a threa...
Definition: JackThread.h:34
jack_session_command_t
Definition: JackSession.h:59