Jack2 1.9.6
|
00001 /* 00002 Copyright (C) 2004-2008 Grame 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 */ 00019 00020 00021 #include "JackRequest.h" 00022 #include "JackWinNamedPipeNotifyChannel.h" 00023 #include "JackError.h" 00024 #include "JackConstants.h" 00025 00026 namespace Jack 00027 { 00028 00029 // Server to client 00030 int JackWinNamedPipeNotifyChannel::Open(const char* name) 00031 { 00032 jack_log("JackWinNamedPipeNotifyChannel::Open name = %s", name); 00033 00034 // Connect to client listen pipe 00035 if (fNotifyPipe.Connect(jack_client_dir, name, 0) < 0) { 00036 jack_error("Cannot connect client pipe"); 00037 return -1; 00038 } 00039 // TODO : use a time out for notifications 00040 fNotifyPipe.SetReadTimeOut(SOCKET_TIME_OUT); 00041 return 0; 00042 } 00043 00044 void JackWinNamedPipeNotifyChannel::Close() 00045 { 00046 jack_log("JackWinNamedPipeNotifyChannel::Close"); 00047 fNotifyPipe.Close(); 00048 } 00049 00050 void JackWinNamedPipeNotifyChannel::ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2, int* result) 00051 { 00052 JackClientNotification event(name, refnum, notify, sync, message, value1, value2); 00053 JackResult res; 00054 00055 // Send notification 00056 if (event.Write(&fNotifyPipe) < 0) { 00057 jack_error("Could not write notification"); 00058 fNotifyPipe.Close(); 00059 *result = -1; 00060 return; 00061 } 00062 00063 // Read the result in "synchronous" mode only 00064 if (sync) { 00065 // Get result : use a time out 00066 if (res.Read(&fNotifyPipe) < 0) { 00067 jack_error("Could not read result"); 00068 fNotifyPipe.Close(); 00069 *result = -1; 00070 } else { 00071 *result = res.fResult; 00072 } 00073 } else { 00074 *result = 0; 00075 } 00076 } 00077 00078 } // end of namespace 00079 00080