Jack2 1.9.12

JackWinNamedPipeServerNotifyChannel.cpp
1 /*
2 Copyright (C) 2004-2006 Grame
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "JackWinNamedPipeServerNotifyChannel.h"
21 #include "JackError.h"
22 #include "JackRequest.h"
23 #include "JackConstants.h"
24 #include "JackNotification.h"
25
26 namespace Jack
27 {
28
29 int JackWinNamedPipeServerNotifyChannel::Open(const char* server_name)
30 {
31 if (fRequestPipe.Connect(jack_server_dir, server_name, 0) < 0) {
32 jack_error("Cannot connect to server pipe");
33 return -1;
34 } else {
35 return 0;
36 }
37 }
38
39 void JackWinNamedPipeServerNotifyChannel::Close()
40 {
41 fRequestPipe.Close();
42 }
43
44 /*
45 The requirement is that the Notification from RT thread can be delivered... not sure using a pipe is adequate here...
46 Can the write operation block?
47 A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise
48 (since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...)
49 */
50 void JackWinNamedPipeServerNotifyChannel::Notify(int refnum, int notify, int value)
51 {
52 JackClientNotificationRequest req(refnum, notify, value);
53 if (req.Write(&fRequestPipe) < 0) {
54 jack_error("Could not write notification ref = %d notify = %d", refnum, notify);
55 }
56 }
57
58 void JackWinNamedPipeServerNotifyChannel::NotifyQuit()
59 {
60 Notify(-1, kQUIT, 0);
61 }
62
63 } // end of namespace
64
65
jack_error
SERVER_EXPORT void jack_error(const char *fmt,...)
Definition: JackError.cpp:92