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 (!JackGlobals::fServerRunning) {
    62     if (req->Write(fRequest) < 0) {
    63         jack_error(
"Could not write request type = %ld", req->fType);
    68     if (res->Read(fRequest) < 0) {
    69         jack_error(
"Could not read result type = %ld", req->fType);
    74     *result = res->fResult;
    77 void JackGenericClientChannel::ServerAsyncCall(JackRequest* req, JackResult* res, 
int* result)
    80     if (jack_tls_get(JackGlobals::fNotificationThread)) {
    81         jack_error(
"Cannot callback the server in notification thread!");
    86     if (!JackGlobals::fServerRunning) {
    92     if (req->Write(fRequest) < 0) {
    93         jack_error(
"Could not write request type = %ld", req->fType);
   100 void JackGenericClientChannel::ClientCheck(
const char* name, 
int uuid, 
char* name_res, 
int protocol, 
int options, 
int* status, 
int* result, 
int open)
   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);
   109 void JackGenericClientChannel::ClientOpen(
const char* name, 
int pid, 
int uuid, 
int* shared_engine, 
int* shared_client, 
int* shared_graph, 
int* result)
   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;
   119 void JackGenericClientChannel::ClientClose(
int refnum, 
int* result)
   121     JackClientCloseRequest req(refnum);
   123     ServerSyncCall(&req, &res, result);
   126 void JackGenericClientChannel::ClientActivate(
int refnum, 
int is_real_time, 
int* result)
   128     JackActivateRequest req(refnum, is_real_time);
   130     ServerSyncCall(&req, &res, result);
   133 void JackGenericClientChannel::ClientDeactivate(
int refnum, 
int* result)
   135     JackDeactivateRequest req(refnum);
   137     ServerSyncCall(&req, &res, result);
   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)
   142     JackPortRegisterRequest req(refnum, name, type, flags, buffer_size);
   143     JackPortRegisterResult res;
   144     ServerSyncCall(&req, &res, result);
   145     *port_index = res.fPortIndex;
   148 void JackGenericClientChannel::PortUnRegister(
int refnum, jack_port_id_t port_index, 
int* result)
   150     JackPortUnRegisterRequest req(refnum, port_index);
   152     ServerSyncCall(&req, &res, result);
   155 void JackGenericClientChannel::PortConnect(
int refnum, 
const char* src, 
const char* dst, 
int* result)
   157     JackPortConnectNameRequest req(refnum, src, dst);
   159     ServerSyncCall(&req, &res, result);
   162 void JackGenericClientChannel::PortDisconnect(
int refnum, 
const char* src, 
const char* dst, 
int* result)
   164     JackPortDisconnectNameRequest req(refnum, src, dst);
   166     ServerSyncCall(&req, &res, result);
   169 void JackGenericClientChannel::PortConnect(
int refnum, jack_port_id_t src, jack_port_id_t dst, 
int* result)
   171     JackPortConnectRequest req(refnum, src, dst);
   173     ServerSyncCall(&req, &res, result);
   176 void JackGenericClientChannel::PortDisconnect(
int refnum, jack_port_id_t src, jack_port_id_t dst, 
int* result)
   178     JackPortDisconnectRequest req(refnum, src, dst);
   180     ServerSyncCall(&req, &res, result);
   183 void JackGenericClientChannel::PortRename(
int refnum, jack_port_id_t port, 
const char* name, 
int* result)
   185     JackPortRenameRequest req(refnum, port, name);
   187     ServerSyncCall(&req, &res, result);
   190 void JackGenericClientChannel::SetBufferSize(jack_nframes_t buffer_size, 
int* result)
   192     JackSetBufferSizeRequest req(buffer_size);
   194     ServerSyncCall(&req, &res, result);
   197 void JackGenericClientChannel::SetFreewheel(
int onoff, 
int* result)
   199     JackSetFreeWheelRequest req(onoff);
   201     ServerSyncCall(&req, &res, result);
   204 void JackGenericClientChannel::ComputeTotalLatencies(
int* result)
   206     JackComputeTotalLatenciesRequest req;
   208     ServerSyncCall(&req, &res, result);
   211 void JackGenericClientChannel::SessionNotify(
int refnum, 
const char* target, jack_session_event_type_t type, 
const char* path, 
jack_session_command_t** result)
   213     JackSessionNotifyRequest req(refnum, path, type, target);
   214     JackSessionNotifyResult res;
   216     ServerSyncCall(&req, &res, &intresult);
   217     *result = res.GetCommands();
   220 void JackGenericClientChannel::SessionReply(
int refnum, 
int* result)
   222     JackSessionReplyRequest req(refnum);
   224     ServerSyncCall(&req, &res, result);
   227 void JackGenericClientChannel::GetUUIDForClientName(
int refnum, 
const char* client_name, 
char* uuid_res, 
int* result)
   229     JackGetUUIDRequest req(client_name);
   231     ServerSyncCall(&req, &res, result);
   232     strncpy(uuid_res, res.fUUID, JACK_UUID_SIZE);
   235 void JackGenericClientChannel::GetClientNameForUUID(
int refnum, 
const char* uuid, 
char* name_res, 
int* result)
   237     JackGetClientNameRequest req(uuid);
   238     JackClientNameResult res;
   239     ServerSyncCall(&req, &res, result);
   240     strncpy(name_res, res.fName, JACK_CLIENT_NAME_SIZE);
   243 void JackGenericClientChannel::ClientHasSessionCallback(
const char* client_name, 
int* result)
   245     JackClientHasSessionCallbackRequest req(client_name);
   247     ServerSyncCall(&req, &res, result);
   250 void JackGenericClientChannel::ReserveClientName(
int refnum, 
const char* client_name, 
const char* uuid, 
int* result)
   252     JackReserveNameRequest req(refnum, client_name, uuid);
   254     ServerSyncCall(&req, &res, result);
   257 void JackGenericClientChannel::ReleaseTimebase(
int refnum, 
int* result)
   259     JackReleaseTimebaseRequest req(refnum);
   261     ServerSyncCall(&req, &res, result);
   264 void JackGenericClientChannel::SetTimebaseCallback(
int refnum, 
int conditional, 
int* result)
   266     JackSetTimebaseCallbackRequest req(refnum, conditional);
   268     ServerSyncCall(&req, &res, result);
   271 void JackGenericClientChannel::GetInternalClientName(
int refnum, 
int int_ref, 
char* name_res, 
int* result)
   273     JackGetInternalClientNameRequest req(refnum, int_ref);
   274     JackGetInternalClientNameResult res;
   275     ServerSyncCall(&req, &res, result);
   276     strcpy(name_res, res.fName);
   279 void JackGenericClientChannel::InternalClientHandle(
int refnum, 
const char* client_name, 
int* status, 
int* int_ref, 
int* result)
   281     JackInternalClientHandleRequest req(refnum, client_name);
   282     JackInternalClientHandleResult res;
   283     ServerSyncCall(&req, &res, result);
   284     *int_ref = res.fIntRefNum;
   285     *status = res.fStatus;
   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)
   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;
   297 void JackGenericClientChannel::InternalClientUnload(
int refnum, 
int int_ref, 
int* status, 
int* result)
   299     JackInternalClientUnloadRequest req(refnum, int_ref);
   300     JackInternalClientUnloadResult res;
   301     ServerSyncCall(&req, &res, result);
   302     *status = res.fStatus;
 SERVER_EXPORT void jack_error(const char *fmt,...)
SERVER_EXPORT void jack_log(const char *fmt,...)