20 #include "JackGenericClientChannel.h"
21 #include "JackClient.h"
22 #include "JackGlobals.h"
23 #include "JackError.h"
28 JackGenericClientChannel::JackGenericClientChannel()
31 JackGenericClientChannel::~JackGenericClientChannel()
34 int JackGenericClientChannel::ServerCheck(
const char* server_name)
36 jack_log(
"JackGenericClientChannel::ServerCheck = %s", server_name);
39 if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
40 jack_error(
"Cannot connect to server request channel");
47 void JackGenericClientChannel::ServerSyncCall(JackRequest* req, JackResult* res,
int* result)
50 if (jack_tls_get(JackGlobals::fNotificationThread)) {
51 jack_error(
"Cannot callback the server in notification thread!");
56 if (req->Write(fRequest) < 0) {
57 jack_error(
"Could not write request type = %ld", req->fType);
62 if (res->Read(fRequest) < 0) {
63 jack_error(
"Could not read result type = %ld", req->fType);
68 *result = res->fResult;
71 void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res,
int* result)
74 if (jack_tls_get(JackGlobals::fNotificationThread)) {
75 jack_error(
"Cannot callback the server in notification thread!");
80 if (req->Write(fRequest) < 0) {
81 jack_error(
"Could not write request type = %ld", req->fType);
88 void JackGenericClientChannel::ClientCheck(
const char* name,
int uuid,
char* name_res,
int protocol,
int options,
int* status,
int* result,
int open)
90 JackClientCheckRequest req(name, protocol, options, uuid, open);
91 JackClientCheckResult res;
92 ServerSyncCall(&req, &res, result);
93 *status = res.fStatus;
94 strcpy(name_res, res.fName);
97 void JackGenericClientChannel::ClientOpen(
const char* name,
int pid,
int uuid,
int* shared_engine,
int* shared_client,
int* shared_graph,
int* result)
99 JackClientOpenRequest req(name, pid, uuid);
100 JackClientOpenResult res;
101 ServerSyncCall(&req, &res, result);
102 *shared_engine = res.fSharedEngine;
103 *shared_client = res.fSharedClient;
104 *shared_graph = res.fSharedGraph;
107 void JackGenericClientChannel::ClientClose(
int refnum,
int* result)
109 JackClientCloseRequest req(refnum);
111 ServerSyncCall(&req, &res, result);
114 void JackGenericClientChannel::ClientActivate(
int refnum,
int is_real_time,
int* result)
116 JackActivateRequest req(refnum, is_real_time);
118 ServerSyncCall(&req, &res, result);
121 void JackGenericClientChannel::ClientDeactivate(
int refnum,
int* result)
123 JackDeactivateRequest req(refnum);
125 ServerSyncCall(&req, &res, result);
128 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)
130 JackPortRegisterRequest req(refnum, name, type, flags, buffer_size);
131 JackPortRegisterResult res;
132 ServerSyncCall(&req, &res, result);
133 *port_index = res.fPortIndex;
136 void JackGenericClientChannel::PortUnRegister(
int refnum, jack_port_id_t port_index,
int* result)
138 JackPortUnRegisterRequest req(refnum, port_index);
140 ServerSyncCall(&req, &res, result);
143 void JackGenericClientChannel::PortConnect(
int refnum,
const char* src,
const char* dst,
int* result)
145 JackPortConnectNameRequest req(refnum, src, dst);
147 ServerSyncCall(&req, &res, result);
150 void JackGenericClientChannel::PortDisconnect(
int refnum,
const char* src,
const char* dst,
int* result)
152 JackPortDisconnectNameRequest req(refnum, src, dst);
154 ServerSyncCall(&req, &res, result);
157 void JackGenericClientChannel::PortConnect(
int refnum, jack_port_id_t src, jack_port_id_t dst,
int* result)
159 JackPortConnectRequest req(refnum, src, dst);
161 ServerSyncCall(&req, &res, result);
164 void JackGenericClientChannel::PortDisconnect(
int refnum, jack_port_id_t src, jack_port_id_t dst,
int* result)
166 JackPortDisconnectRequest req(refnum, src, dst);
168 ServerSyncCall(&req, &res, result);
171 void JackGenericClientChannel::PortRename(
int refnum, jack_port_id_t port,
const char* name,
int* result)
173 JackPortRenameRequest req(refnum, port, name);
175 ServerSyncCall(&req, &res, result);
178 void JackGenericClientChannel::SetBufferSize(jack_nframes_t buffer_size,
int* result)
180 JackSetBufferSizeRequest req(buffer_size);
182 ServerSyncCall(&req, &res, result);
185 void JackGenericClientChannel::SetFreewheel(
int onoff,
int* result)
187 JackSetFreeWheelRequest req(onoff);
189 ServerSyncCall(&req, &res, result);
192 void JackGenericClientChannel::ComputeTotalLatencies(
int* result)
194 JackComputeTotalLatenciesRequest req;
196 ServerSyncCall(&req, &res, result);
199 void JackGenericClientChannel::SessionNotify(
int refnum,
const char* target, jack_session_event_type_t type,
const char* path,
jack_session_command_t** result)
201 JackSessionNotifyRequest req(refnum, path, type, target);
202 JackSessionNotifyResult res;
204 ServerSyncCall(&req, &res, &intresult);
205 *result = res.GetCommands();
208 void JackGenericClientChannel::SessionReply(
int refnum,
int* result)
210 JackSessionReplyRequest req(refnum);
212 ServerSyncCall(&req, &res, result);
215 void JackGenericClientChannel::GetUUIDForClientName(
int refnum,
const char* client_name,
char* uuid_res,
int* result)
217 JackGetUUIDRequest req(client_name);
219 ServerSyncCall(&req, &res, result);
220 strncpy(uuid_res, res.fUUID, JACK_UUID_SIZE);
223 void JackGenericClientChannel::GetClientNameForUUID(
int refnum,
const char* uuid,
char* name_res,
int* result)
225 JackGetClientNameRequest req(uuid);
226 JackClientNameResult res;
227 ServerSyncCall(&req, &res, result);
228 strncpy(name_res, res.fName, JACK_CLIENT_NAME_SIZE);
231 void JackGenericClientChannel::ClientHasSessionCallback(
const char* client_name,
int* result)
233 JackClientHasSessionCallbackRequest req(client_name);
235 ServerSyncCall(&req, &res, result);
238 void JackGenericClientChannel::ReserveClientName(
int refnum,
const char* client_name,
const char* uuid,
int* result)
240 JackReserveNameRequest req(refnum, client_name, uuid);
242 ServerSyncCall(&req, &res, result);
245 void JackGenericClientChannel::ReleaseTimebase(
int refnum,
int* result)
247 JackReleaseTimebaseRequest req(refnum);
249 ServerSyncCall(&req, &res, result);
252 void JackGenericClientChannel::SetTimebaseCallback(
int refnum,
int conditional,
int* result)
254 JackSetTimebaseCallbackRequest req(refnum, conditional);
256 ServerSyncCall(&req, &res, result);
259 void JackGenericClientChannel::GetInternalClientName(
int refnum,
int int_ref,
char* name_res,
int* result)
261 JackGetInternalClientNameRequest req(refnum, int_ref);
262 JackGetInternalClientNameResult res;
263 ServerSyncCall(&req, &res, result);
264 strcpy(name_res, res.fName);
267 void JackGenericClientChannel::InternalClientHandle(
int refnum,
const char* client_name,
int* status,
int* int_ref,
int* result)
269 JackInternalClientHandleRequest req(refnum, client_name);
270 JackInternalClientHandleResult res;
271 ServerSyncCall(&req, &res, result);
272 *int_ref = res.fIntRefNum;
273 *status = res.fStatus;
276 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)
278 JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options, uuid);
279 JackInternalClientLoadResult res;
280 ServerSyncCall(&req, &res, result);
281 *int_ref = res.fIntRefNum;
282 *status = res.fStatus;
285 void JackGenericClientChannel::InternalClientUnload(
int refnum,
int int_ref,
int* status,
int* result)
287 JackInternalClientUnloadRequest req(refnum, int_ref);
288 JackInternalClientUnloadResult res;
289 ServerSyncCall(&req, &res, result);
290 *status = res.fStatus;
SERVER_EXPORT void jack_error(const char *fmt,...)
SERVER_EXPORT void jack_log(const char *fmt,...)