Jack2
1.9.8
|
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 #ifndef __JackWinNamedPipeServerChannel__ 00022 #define __JackWinNamedPipeServerChannel__ 00023 00024 #include "JackWinNamedPipe.h" 00025 #include "JackPlatformPlug.h" 00026 #include "JackConstants.h" 00027 #include <list> 00028 00029 namespace Jack 00030 { 00031 00032 class JackServer; 00033 00034 class JackClientPipeThread : public JackRunnableInterface 00035 { 00036 00037 private: 00038 00039 JackWinNamedPipeClient* fPipe; 00040 JackServer* fServer; 00041 JackThread fThread; 00042 int fRefNum; 00043 00044 void ClientAdd(char* name, int pid, int uuid, int* shared_engine, int* shared_client, int* shared_graph, int* result); 00045 void ClientRemove(); 00046 void ClientKill(); 00047 00048 static HANDLE fMutex; 00049 00050 public: 00051 00052 JackClientPipeThread(JackWinNamedPipeClient* pipe); 00053 virtual ~JackClientPipeThread(); 00054 00055 int Open(JackServer* server); // Open the Server/Client connection 00056 void Close(); // Close the Server/Client connection 00057 00058 bool HandleRequest(); 00059 00060 // JackRunnableInterface interface 00061 bool Execute(); 00062 00063 // To be used for find out if the object can be deleted 00064 bool IsRunning() 00065 { 00066 return (fRefNum >= 0); 00067 } 00068 }; 00069 00074 class JackWinNamedPipeServerChannel : public JackRunnableInterface 00075 { 00076 00077 private: 00078 00079 JackWinNamedPipeServer fRequestListenPipe; // Pipe to create request socket for the client 00080 JackServer* fServer; 00081 JackThread fThread; // Thread to execute the event loop 00082 char fServerName[JACK_SERVER_CONTROL_NAME_SIZE]; 00083 00084 std::list<JackClientPipeThread*> fClientList; 00085 00086 void ClientAdd(JackWinNamedPipeClient* pipe); 00087 00088 public: 00089 00090 JackWinNamedPipeServerChannel(); 00091 ~JackWinNamedPipeServerChannel(); 00092 00093 int Open(const char* server_name, JackServer* server); // Open the Server/Client connection 00094 void Close(); // Close the Server/Client connection 00095 00096 int Start(); 00097 void Stop(); 00098 00099 // JackRunnableInterface interface 00100 bool Init(); 00101 bool Execute(); 00102 }; 00103 00104 00105 } // end of namespace 00106 00107 #endif 00108