20 #include "JackSocketClientChannel.h"    21 #include "JackRequest.h"    22 #include "JackClient.h"    23 #include "JackGlobals.h"    24 #include "JackError.h"    29 JackSocketClientChannel::JackSocketClientChannel()
    30     :JackGenericClientChannel(), fThread(this)
    32     fRequest = 
new JackClientSocket();
    33     fNotificationSocket = NULL;
    36 JackSocketClientChannel::~JackSocketClientChannel()
    39     delete fNotificationSocket;
    42 int JackSocketClientChannel::Open(
const char* server_name, 
const char* name, 
int uuid, 
char* name_res, JackClient* client, jack_options_t options, jack_status_t* status)
    45     jack_log(
"JackSocketClientChannel::Open name = %s", name);
    50     if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
    56     JackGlobals::fServerRunning = 
true;
    59     ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (
int)options, (
int*)status, &result, 
true);
    61         int status1 = *status;
    62         if (status1 & JackVersionError) {
    63             jack_error(
"JACK protocol mismatch %d", JACK_PROTOCOL_VERSION);
    65             jack_error(
"Client name = %s conflits with another running client", name);
    70     if (fNotificationListenSocket.Bind(jack_client_dir, name_res, 0) < 0) {
    79     fNotificationListenSocket.Close();
    83 void JackSocketClientChannel::Close()
    86     fNotificationListenSocket.Close();
    87     if (fNotificationSocket) {
    88         fNotificationSocket->Close();
    92 int JackSocketClientChannel::Start()
    94     jack_log(
"JackSocketClientChannel::Start");
    98     if (fThread.StartSync() != 0) {
    99         jack_error(
"Cannot start Jack client listener");
   106 void JackSocketClientChannel::Stop()
   108     jack_log(
"JackSocketClientChannel::Stop");
   114     jack_log(
"JackSocketClientChannel::Init");
   115     fNotificationSocket = fNotificationListenSocket.Accept();
   118     fNotificationListenSocket.Close();
   121     if (!jack_tls_set(JackGlobals::fNotificationThread, 
this)) {
   122         jack_error(
"Failed to set thread notification key");
   125     if (!fNotificationSocket) {
   126         jack_error(
"JackSocketClientChannel: cannot establish notication socket");
   133 bool JackSocketClientChannel::Execute()
   138     if (event.Read(fNotificationSocket) < 0) {
   139         jack_error(
"JackSocketClientChannel read fail");
   143     res.fResult = fClient->ClientNotify(event.fRefNum, event.fName, event.fNotify, event.fSync, event.fMessage, event.fValue1, event.fValue2);
   146         if (res.Write(fNotificationSocket) < 0) {
   147             jack_error(
"JackSocketClientChannel write fail");
   154     fNotificationSocket->Close();
   155     fClient->ShutDown(jack_status_t(JackFailure | JackServerError), JACK_SERVER_FAILURE);
 SERVER_EXPORT void jack_error(const char *fmt,...)
SERVER_EXPORT void jack_log(const char *fmt,...)