Init engine fields, cleanup.
[jack2.git] / posix / JackSocketServerNotifyChannel.cpp
blobdf7381f1911946dee52e5c6e52b0b31010e2c971
1 /*
2 Copyright (C) 2004-2008 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "JackSocketServerNotifyChannel.h"
21 #include "JackError.h"
22 #include "JackRequest.h"
23 #include "JackConstants.h"
24 #include "JackNotification.h"
26 namespace Jack
29 int JackSocketServerNotifyChannel::Open(const char* server_name)
31 if (fRequestSocket.Connect(jack_server_dir, server_name, 0) < 0) {
32 jack_error("Cannot connect to server socket");
33 return -1;
34 } else {
35 fRequestSocket.SetNonBlocking(true);
36 return 0;
40 void JackSocketServerNotifyChannel::Close()
42 fRequestSocket.Close();
46 The requirement is that the Notification from RT thread can be delivered... not sure using a socket is adequate here...
47 Can the write operation block?
48 A non blocking write operation shoud be used : check if write can succeed, and ignore the notification otherwise
49 (since its mainly used for XRun, ignoring a notification is OK, successive XRun will come...)
51 void JackSocketServerNotifyChannel::Notify(int refnum, int notify, int value)
53 JackClientNotificationRequest req(refnum, notify, value);
54 if (req.Write(&fRequestSocket) < 0) {
55 jack_error("Could not write request ref = %d notify = %d", refnum, notify);
59 void JackSocketServerNotifyChannel::NotifyQuit()
61 JackClientNotificationRequest req(-1, kQUIT, 0);
62 if (req.Write(&fRequestSocket) < 0) {
63 jack_error("Could not write request ref = %d notify = %d", -1, kQUIT);
68 } // end of namespace