Jack2: JackGenericClientChannel.cpp Source File

Jack2 1.9.12

JackGenericClientChannel.cpp
1 /*
2 Copyright (C) 2004-2008 Grame
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18 */
19
20 #include "JackGenericClientChannel.h"
21 #include "JackClient.h"
22 #include "JackGlobals.h"
23 #include "JackError.h"
24
25 namespace Jack
26 {
27
28 JackGenericClientChannel::JackGenericClientChannel()
29 {}
30
31 JackGenericClientChannel::~JackGenericClientChannel()
32 {}
33
34 int JackGenericClientChannel::ServerCheck(const char* server_name)
35 {
36 jack_log("JackGenericClientChannel::ServerCheck = %s", server_name);
37
38 // Connect to server
39 if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
40 jack_error("Cannot connect to server request channel");
41 return -1;
42 } else {
43 return 0;
44 }
45 }
46
47 void JackGenericClientChannel::ServerSyncCall(JackRequest* req, JackResult* res, int* result)
48 {
49 // Check call context
50 if (jack_tls_get(JackGlobals::fNotificationThread)) {
51 jack_error("Cannot callback the server in notification thread!");
52 *result = -1;
53 return;
54 }
55
56 if (!JackGlobals::fServerRunning) {
57 jack_error("Server is not running");
58 *result = -1;
59 return;
60 }
61
62 if (req->Write(fRequest) < 0) {
63 jack_error("Could not write request type = %ld", req->fType);
64 *result = -1;
65 return;
66 }
67
68 if (res->Read(fRequest) < 0) {
69 jack_error("Could not read result type = %ld", req->fType);
70 *result = -1;
71 return;
72 }
73
74 *result = res->fResult;
75 }
76
77 void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res, int* result)
78 {
79 // Check call context
80 if (jack_tls_get(JackGlobals::fNotificationThread)) {
81 jack_error("Cannot callback the server in notification thread!");
82 *result = -1;
83 return;
84 }
85
86 if (!JackGlobals::fServerRunning) {
87 jack_error("Server is not running");
88 *result = -1;
89 return;
90 }
91
92 if (req->Write(fRequest) < 0) {
93 jack_error("Could not write request type = %ld", req->fType);
94 *result = -1;
95 } else {
96 *result = 0;
97 }
98 }
99
100 void JackGenericClientChannel::ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open)
101 {
102 JackClientCheckRequest req(name, protocol, options, uuid, open);
103 JackClientCheckResult res;
104 ServerSyncCall(&req, &res, result);
105 *status |= res.fStatus;
106 strcpy(name_res, res.fName);
107 }
108
109 void JackGenericClientChannel::ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result)
110 {
111 JackClientOpenRequest req(name, pid, uuid);
112 JackClientOpenResult res;
113 ServerSyncCall(&req, &res, result);
114 *shared_engine = res.fSharedEngine;
115 *shared_client = res.fSharedClient;
116 *shared_graph = res.fSharedGraph;
117 }
118
119 void JackGenericClientChannel::ClientClose(int refnum, int* result)
120 {
121 JackClientCloseRequest req(refnum);
122 JackResult res;
123 ServerSyncCall(&req, &res, result);
124 }
125
126 void JackGenericClientChannel::ClientActivate(int refnum, int is_real_time, int* result)
127 {
128 JackActivateRequest req(refnum, is_real_time);
129 JackResult res;
130 ServerSyncCall(&req, &res, result);
131 }
132
133 void JackGenericClientChannel::ClientDeactivate(int refnum, int* result)
134 {
135 JackDeactivateRequest req(refnum);
136 JackResult res;
137 ServerSyncCall(&req, &res, result);
138 }
139
140 void JackGenericClientChannel::PortRegister(int refnum, const char* name, const char* type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index, int* result)
141 {
142 JackPortRegisterRequest req(refnum, name, type, flags, buffer_size);
143 JackPortRegisterResult res;
144 ServerSyncCall(&req, &res, result);
145 *port_index = res.fPortIndex;
146 }
147
148 void JackGenericClientChannel::PortUnRegister(int refnum, jack_port_id_t port_index, int* result)
149 {
150 JackPortUnRegisterRequest req(refnum, port_index);
151 JackResult res;
152 ServerSyncCall(&req, &res, result);
153 }
154
155 void JackGenericClientChannel::PortConnect(int refnum, const char* src, const char* dst, int* result)
156 {
157 JackPortConnectNameRequest req(refnum, src, dst);
158 JackResult res;
159 ServerSyncCall(&req, &res, result);
160 }
161
162 void JackGenericClientChannel::PortDisconnect(int refnum, const char* src, const char* dst, int* result)
163 {
164 JackPortDisconnectNameRequest req(refnum, src, dst);
165 JackResult res;
166 ServerSyncCall(&req, &res, result);
167 }
168
169 void JackGenericClientChannel::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result)
170 {
171 JackPortConnectRequest req(refnum, src, dst);
172 JackResult res;
173 ServerSyncCall(&req, &res, result);
174 }
175
176 void JackGenericClientChannel::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result)
177 {
178 JackPortDisconnectRequest req(refnum, src, dst);
179 JackResult res;
180 ServerSyncCall(&req, &res, result);
181 }
182
183 void JackGenericClientChannel::PortRename(int refnum, jack_port_id_t port, const char* name, int* result)
184 {
185 JackPortRenameRequest req(refnum, port, name);
186 JackResult res;
187 ServerSyncCall(&req, &res, result);
188 }
189
190 void JackGenericClientChannel::SetBufferSize(jack_nframes_t buffer_size, int* result)
191 {
192 JackSetBufferSizeRequest req(buffer_size);
193 JackResult res;
194 ServerSyncCall(&req, &res, result);
195 }
196
197 void JackGenericClientChannel::SetFreewheel(int onoff, int* result)
198 {
199 JackSetFreeWheelRequest req(onoff);
200 JackResult res;
201 ServerSyncCall(&req, &res, result);
202 }
203
204 void JackGenericClientChannel::ComputeTotalLatencies(int* result)
205 {
206 JackComputeTotalLatenciesRequest req;
207 JackResult res;
208 ServerSyncCall(&req, &res, result);
209 }
210
211 void JackGenericClientChannel::SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result)
212 {
213 JackSessionNotifyRequest req(refnum, path, type, target);
214 JackSessionNotifyResult res;
215 int intresult;
216 ServerSyncCall(&req, &res, &intresult);
217 *result = res.GetCommands();
218 }
219
220 void JackGenericClientChannel::SessionReply(int refnum, int* result)
221 {
222 JackSessionReplyRequest req(refnum);
223 JackResult res;
224 ServerSyncCall(&req, &res, result);
225 }
226
227 void JackGenericClientChannel::GetUUIDForClientName(int refnum, const char* client_name, char* uuid_res, int* result)
228 {
229 JackGetUUIDRequest req(client_name);
230 JackUUIDResult res;
231 ServerSyncCall(&req, &res, result);
232 strncpy(uuid_res, res.fUUID, JACK_UUID_SIZE);
233 }
234
235 void JackGenericClientChannel::GetClientNameForUUID(int refnum, const char* uuid, char* name_res, int* result)
236 {
237 JackGetClientNameRequest req(uuid);
238 JackClientNameResult res;
239 ServerSyncCall(&req, &res, result);
240 strncpy(name_res, res.fName, JACK_CLIENT_NAME_SIZE);
241 }
242
243 void JackGenericClientChannel::ClientHasSessionCallback(const char* client_name, int* result)
244 {
245 JackClientHasSessionCallbackRequest req(client_name);
246 JackResult res;
247 ServerSyncCall(&req, &res, result);
248 }
249
250 void JackGenericClientChannel::ReserveClientName(int refnum, const char* client_name, const char* uuid, int* result)
251 {
252 JackReserveNameRequest req(refnum, client_name, uuid);
253 JackResult res;
254 ServerSyncCall(&req, &res, result);
255 }
256
257 void JackGenericClientChannel::ReleaseTimebase(int refnum, int* result)
258 {
259 JackReleaseTimebaseRequest req(refnum);
260 JackResult res;
261 ServerSyncCall(&req, &res, result);
262 }
263
264 void JackGenericClientChannel::SetTimebaseCallback(int refnum, int conditional, int* result)
265 {
266 JackSetTimebaseCallbackRequest req(refnum, conditional);
267 JackResult res;
268 ServerSyncCall(&req, &res, result);
269 }
270
271 void JackGenericClientChannel::GetInternalClientName(int refnum, int int_ref, char* name_res, int* result)
272 {
273 JackGetInternalClientNameRequest req(refnum, int_ref);
274 JackGetInternalClientNameResult res;
275 ServerSyncCall(&req, &res, result);
276 strcpy(name_res, res.fName);
277 }
278
279 void JackGenericClientChannel::InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result)
280 {
281 JackInternalClientHandleRequest req(refnum, client_name);
282 JackInternalClientHandleResult res;
283 ServerSyncCall(&req, &res, result);
284 *int_ref = res.fIntRefNum;
285 *status = res.fStatus;
286 }
287
288 void JackGenericClientChannel::InternalClientLoad(int refnum, const char* client_name, const char* so_name, const char* objet_data, int options, int* status, int* int_ref, int uuid, int* result)
289 {
290 JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options, uuid);
291 JackInternalClientLoadResult res;
292 ServerSyncCall(&req, &res, result);
293 *int_ref = res.fIntRefNum;
294 *status = res.fStatus;
295 }
296
297 void JackGenericClientChannel::InternalClientUnload(int refnum, int int_ref, int* status, int* result)
298 {
299 JackInternalClientUnloadRequest req(refnum, int_ref);
300 JackInternalClientUnloadResult res;
301 ServerSyncCall(&req, &res, result);
302 *status = res.fStatus;
303 }
304
305 } // end of namespace
306
307
308
309
310
jack_log
SERVER_EXPORT void jack_log(const char *fmt,...)
Definition: JackError.cpp:108
jack_error
SERVER_EXPORT void jack_error(const char *fmt,...)
Definition: JackError.cpp:92
jack_session_command_t
Definition: JackSession.h:59