jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.7KB

  1. /*
  2. Copyright (C) 2004-2006 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __JackWinNamedPipeServerChannel__
  16. #define __JackWinNamedPipeServerChannel__
  17. #include "JackChannel.h"
  18. #include "JackWinNamedPipe.h"
  19. #include "JackPlatformThread.h"
  20. #include <map>
  21. #include <list>
  22. namespace Jack
  23. {
  24. class JackClientPipeThread : public JackRunnableInterface
  25. {
  26. private:
  27. JackWinNamedPipeClient* fPipe;
  28. JackServer* fServer;
  29. JackThread fThread;
  30. int fRefNum;
  31. void ClientAdd(char* name, int pid, int* shared_engine, int* shared_client, int* shared_graph, int* result);
  32. void ClientRemove();
  33. void ClientKill();
  34. static HANDLE fMutex;
  35. public:
  36. JackClientPipeThread(JackWinNamedPipeClient* pipe);
  37. virtual ~JackClientPipeThread();
  38. int Open(JackServer* server); // Open the Server/Client connection
  39. void Close(); // Close the Server/Client connection
  40. bool HandleRequest();
  41. // JackRunnableInterface interface
  42. bool Execute();
  43. // To be used for find out if the object can be deleted
  44. bool IsRunning()
  45. {
  46. return (fRefNum >= 0);
  47. }
  48. };
  49. /*!
  50. \brief JackServerChannel using pipe.
  51. */
  52. class JackWinNamedPipeServerChannel : public JackRunnableInterface
  53. {
  54. private:
  55. JackWinNamedPipeServer fRequestListenPipe; // Pipe to create request socket for the client
  56. JackServer* fServer;
  57. JackThread fThread; // Thread to execute the event loop
  58. char fServerName[64];
  59. std::list<JackClientPipeThread*> fClientList;
  60. void ClientAdd(JackWinNamedPipeClient* pipe);
  61. public:
  62. JackWinNamedPipeServerChannel();
  63. ~JackWinNamedPipeServerChannel();
  64. int Open(const char* server_name, JackServer* server); // Open the Server/Client connection
  65. void Close(); // Close the Server/Client connection
  66. // JackRunnableInterface interface
  67. bool Init();
  68. bool Execute();
  69. };
  70. } // end of namespace
  71. #endif