Jack2 1.9.10
|
00001 /* 00002 Copyright (C) 2004-2008 Grame 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 */ 00019 00020 #include "JackGenericClientChannel.h" 00021 #include "JackClient.h" 00022 #include "JackGlobals.h" 00023 #include "JackError.h" 00024 00025 namespace Jack 00026 { 00027 00028 JackGenericClientChannel::JackGenericClientChannel() 00029 {} 00030 00031 JackGenericClientChannel::~JackGenericClientChannel() 00032 {} 00033 00034 int JackGenericClientChannel::ServerCheck(const char* server_name) 00035 { 00036 jack_log("JackGenericClientChannel::ServerCheck = %s", server_name); 00037 00038 // Connect to server 00039 if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) { 00040 jack_error("Cannot connect to server request channel"); 00041 return -1; 00042 } else { 00043 return 0; 00044 } 00045 } 00046 00047 void JackGenericClientChannel::ServerSyncCall(JackRequest* req, JackResult* res, int* result) 00048 { 00049 // Check call context 00050 if (jack_tls_get(JackGlobals::fNotificationThread)) { 00051 jack_error("Cannot callback the server in notification thread!"); 00052 *result = -1; 00053 return; 00054 } 00055 00056 if (!JackGlobals::fServerRunning) { 00057 jack_error("Server is not running"); 00058 *result = -1; 00059 return; 00060 } 00061 00062 if (req->Write(fRequest) < 0) { 00063 jack_error("Could not write request type = %ld", req->fType); 00064 *result = -1; 00065 return; 00066 } 00067 00068 if (res->Read(fRequest) < 0) { 00069 jack_error("Could not read result type = %ld", req->fType); 00070 *result = -1; 00071 return; 00072 } 00073 00074 *result = res->fResult; 00075 } 00076 00077 void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res, int* result) 00078 { 00079 // Check call context 00080 if (jack_tls_get(JackGlobals::fNotificationThread)) { 00081 jack_error("Cannot callback the server in notification thread!"); 00082 *result = -1; 00083 return; 00084 } 00085 00086 if (!JackGlobals::fServerRunning) { 00087 jack_error("Server is not running"); 00088 *result = -1; 00089 return; 00090 } 00091 00092 if (req->Write(fRequest) < 0) { 00093 jack_error("Could not write request type = %ld", req->fType); 00094 *result = -1; 00095 } else { 00096 *result = 0; 00097 } 00098 } 00099 00100 void JackGenericClientChannel::ClientCheck(const char* name, int uuid, char* name_res, int protocol, int options, int* status, int* result, int open) 00101 { 00102 JackClientCheckRequest req(name, protocol, options, uuid, open); 00103 JackClientCheckResult res; 00104 ServerSyncCall(&req, &res, result); 00105 *status = res.fStatus; 00106 strcpy(name_res, res.fName); 00107 } 00108 00109 void JackGenericClientChannel::ClientOpen(const char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result) 00110 { 00111 JackClientOpenRequest req(name, pid, uuid); 00112 JackClientOpenResult res; 00113 ServerSyncCall(&req, &res, result); 00114 *shared_engine = res.fSharedEngine; 00115 *shared_client = res.fSharedClient; 00116 *shared_graph = res.fSharedGraph; 00117 } 00118 00119 void JackGenericClientChannel::ClientClose(int refnum, int* result) 00120 { 00121 JackClientCloseRequest req(refnum); 00122 JackResult res; 00123 ServerSyncCall(&req, &res, result); 00124 } 00125 00126 void JackGenericClientChannel::ClientActivate(int refnum, int is_real_time, int* result) 00127 { 00128 JackActivateRequest req(refnum, is_real_time); 00129 JackResult res; 00130 ServerSyncCall(&req, &res, result); 00131 } 00132 00133 void JackGenericClientChannel::ClientDeactivate(int refnum, int* result) 00134 { 00135 JackDeactivateRequest req(refnum); 00136 JackResult res; 00137 ServerSyncCall(&req, &res, result); 00138 } 00139 00140 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) 00141 { 00142 JackPortRegisterRequest req(refnum, name, type, flags, buffer_size); 00143 JackPortRegisterResult res; 00144 ServerSyncCall(&req, &res, result); 00145 *port_index = res.fPortIndex; 00146 } 00147 00148 void JackGenericClientChannel::PortUnRegister(int refnum, jack_port_id_t port_index, int* result) 00149 { 00150 JackPortUnRegisterRequest req(refnum, port_index); 00151 JackResult res; 00152 ServerSyncCall(&req, &res, result); 00153 } 00154 00155 void JackGenericClientChannel::PortConnect(int refnum, const char* src, const char* dst, int* result) 00156 { 00157 JackPortConnectNameRequest req(refnum, src, dst); 00158 JackResult res; 00159 ServerSyncCall(&req, &res, result); 00160 } 00161 00162 void JackGenericClientChannel::PortDisconnect(int refnum, const char* src, const char* dst, int* result) 00163 { 00164 JackPortDisconnectNameRequest req(refnum, src, dst); 00165 JackResult res; 00166 ServerSyncCall(&req, &res, result); 00167 } 00168 00169 void JackGenericClientChannel::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result) 00170 { 00171 JackPortConnectRequest req(refnum, src, dst); 00172 JackResult res; 00173 ServerSyncCall(&req, &res, result); 00174 } 00175 00176 void JackGenericClientChannel::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst, int* result) 00177 { 00178 JackPortDisconnectRequest req(refnum, src, dst); 00179 JackResult res; 00180 ServerSyncCall(&req, &res, result); 00181 } 00182 00183 void JackGenericClientChannel::PortRename(int refnum, jack_port_id_t port, const char* name, int* result) 00184 { 00185 JackPortRenameRequest req(refnum, port, name); 00186 JackResult res; 00187 ServerSyncCall(&req, &res, result); 00188 } 00189 00190 void JackGenericClientChannel::SetBufferSize(jack_nframes_t buffer_size, int* result) 00191 { 00192 JackSetBufferSizeRequest req(buffer_size); 00193 JackResult res; 00194 ServerSyncCall(&req, &res, result); 00195 } 00196 00197 void JackGenericClientChannel::SetFreewheel(int onoff, int* result) 00198 { 00199 JackSetFreeWheelRequest req(onoff); 00200 JackResult res; 00201 ServerSyncCall(&req, &res, result); 00202 } 00203 00204 void JackGenericClientChannel::ComputeTotalLatencies(int* result) 00205 { 00206 JackComputeTotalLatenciesRequest req; 00207 JackResult res; 00208 ServerSyncCall(&req, &res, result); 00209 } 00210 00211 void JackGenericClientChannel::SessionNotify(int refnum, const char* target, jack_session_event_type_t type, const char* path, jack_session_command_t** result) 00212 { 00213 JackSessionNotifyRequest req(refnum, path, type, target); 00214 JackSessionNotifyResult res; 00215 int intresult; 00216 ServerSyncCall(&req, &res, &intresult); 00217 *result = res.GetCommands(); 00218 } 00219 00220 void JackGenericClientChannel::SessionReply(int refnum, int* result) 00221 { 00222 JackSessionReplyRequest req(refnum); 00223 JackResult res; 00224 ServerSyncCall(&req, &res, result); 00225 } 00226 00227 void JackGenericClientChannel::GetUUIDForClientName(int refnum, const char* client_name, char* uuid_res, int* result) 00228 { 00229 JackGetUUIDRequest req(client_name); 00230 JackUUIDResult res; 00231 ServerSyncCall(&req, &res, result); 00232 strncpy(uuid_res, res.fUUID, JACK_UUID_SIZE); 00233 } 00234 00235 void JackGenericClientChannel::GetClientNameForUUID(int refnum, const char* uuid, char* name_res, int* result) 00236 { 00237 JackGetClientNameRequest req(uuid); 00238 JackClientNameResult res; 00239 ServerSyncCall(&req, &res, result); 00240 strncpy(name_res, res.fName, JACK_CLIENT_NAME_SIZE); 00241 } 00242 00243 void JackGenericClientChannel::ClientHasSessionCallback(const char* client_name, int* result) 00244 { 00245 JackClientHasSessionCallbackRequest req(client_name); 00246 JackResult res; 00247 ServerSyncCall(&req, &res, result); 00248 } 00249 00250 void JackGenericClientChannel::ReserveClientName(int refnum, const char* client_name, const char* uuid, int* result) 00251 { 00252 JackReserveNameRequest req(refnum, client_name, uuid); 00253 JackResult res; 00254 ServerSyncCall(&req, &res, result); 00255 } 00256 00257 void JackGenericClientChannel::ReleaseTimebase(int refnum, int* result) 00258 { 00259 JackReleaseTimebaseRequest req(refnum); 00260 JackResult res; 00261 ServerSyncCall(&req, &res, result); 00262 } 00263 00264 void JackGenericClientChannel::SetTimebaseCallback(int refnum, int conditional, int* result) 00265 { 00266 JackSetTimebaseCallbackRequest req(refnum, conditional); 00267 JackResult res; 00268 ServerSyncCall(&req, &res, result); 00269 } 00270 00271 void JackGenericClientChannel::GetInternalClientName(int refnum, int int_ref, char* name_res, int* result) 00272 { 00273 JackGetInternalClientNameRequest req(refnum, int_ref); 00274 JackGetInternalClientNameResult res; 00275 ServerSyncCall(&req, &res, result); 00276 strcpy(name_res, res.fName); 00277 } 00278 00279 void JackGenericClientChannel::InternalClientHandle(int refnum, const char* client_name, int* status, int* int_ref, int* result) 00280 { 00281 JackInternalClientHandleRequest req(refnum, client_name); 00282 JackInternalClientHandleResult res; 00283 ServerSyncCall(&req, &res, result); 00284 *int_ref = res.fIntRefNum; 00285 *status = res.fStatus; 00286 } 00287 00288 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) 00289 { 00290 JackInternalClientLoadRequest req(refnum, client_name, so_name, objet_data, options, uuid); 00291 JackInternalClientLoadResult res; 00292 ServerSyncCall(&req, &res, result); 00293 *int_ref = res.fIntRefNum; 00294 *status = res.fStatus; 00295 } 00296 00297 void JackGenericClientChannel::InternalClientUnload(int refnum, int int_ref, int* status, int* result) 00298 { 00299 JackInternalClientUnloadRequest req(refnum, int_ref); 00300 JackInternalClientUnloadResult res; 00301 ServerSyncCall(&req, &res, result); 00302 *status = res.fStatus; 00303 } 00304 00305 } // end of namespace 00306 00307 00308 00309 00310