21 #include "JackWinNamedPipeClientChannel.h" 22 #include "JackRequest.h" 23 #include "JackClient.h" 24 #include "JackGlobals.h" 25 #include "JackError.h" 30 JackWinNamedPipeClientChannel::JackWinNamedPipeClientChannel()
31 :JackGenericClientChannel(),fThread(this)
33 fRequest =
new JackWinNamedPipeClient();
36 JackWinNamedPipeClientChannel::~JackWinNamedPipeClientChannel()
41 int JackWinNamedPipeClientChannel::Open(
const char* server_name,
const char* name,
int uuid,
char* name_res, JackClient* client, jack_options_t options, jack_status_t* status)
44 jack_log(
"JackWinNamedPipeClientChannel::Open name = %s", name);
57 if (fRequest->Connect(jack_server_dir, server_name, 0) < 0) {
63 JackGlobals::fServerRunning =
true;
66 ClientCheck(name, uuid, name_res, JACK_PROTOCOL_VERSION, (
int)options, (
int*)status, &result,
true);
68 int status1 = *status;
69 if (status1 & JackVersionError) {
70 jack_error(
"JACK protocol mismatch %d", JACK_PROTOCOL_VERSION);
72 jack_error(
"Client name = %s conflits with another running client", name);
76 if (fNotificationListenPipe.Bind(jack_client_dir, name_res, 0) < 0) {
85 fNotificationListenPipe.Close();
89 void JackWinNamedPipeClientChannel::Close()
92 fNotificationListenPipe.Close();
97 int JackWinNamedPipeClientChannel::Start()
99 jack_log(
"JackWinNamedPipeClientChannel::Start");
103 if (fThread.StartSync() != 0) {
104 jack_error(
"Cannot start Jack client listener");
111 void JackWinNamedPipeClientChannel::Stop()
113 jack_log(
"JackWinNamedPipeClientChannel::Stop");
119 jack_log(
"JackWinNamedPipeClientChannel::Init");
122 if (!jack_tls_set(JackGlobals::fNotificationThread,
this)) {
123 jack_error(
"Failed to set thread notification key");
126 if (!fNotificationListenPipe.Accept()) {
127 jack_error(
"JackWinNamedPipeClientChannel: cannot establish notification pipe");
134 bool JackWinNamedPipeClientChannel::Execute()
139 if (event.Read(&fNotificationListenPipe) < 0) {
140 jack_error(
"JackWinNamedPipeClientChannel read fail");
144 res.fResult = fClient->ClientNotify(event.fRefNum, event.fName, event.fNotify, event.fSync, event.fMessage, event.fValue1, event.fValue2);
147 if (res.Write(&fNotificationListenPipe) < 0) {
148 jack_error(
"JackWinNamedPipeClientChannel write fail");
156 fNotificationListenPipe.Close();
158 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,...)