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.

116 lines
3.0KB

  1. /*
  2. Copyright (C) 2008 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 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 General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef __JACKNETMASTER_H__
  16. #define __JACKNETMASTER_H__
  17. #include "JackNetTool.h"
  18. #include "thread.h"
  19. #include "jack.h"
  20. #include <list>
  21. namespace Jack
  22. {
  23. class JackNetMasterManager;
  24. class JackNetMaster
  25. {
  26. friend class JackNetMasterManager;
  27. private:
  28. static int SetProcess ( jack_nframes_t nframes, void* arg );
  29. JackNetMasterManager* fMasterManager;
  30. session_params_t fParams;
  31. struct sockaddr_in fAddr;
  32. struct sockaddr_in fMcastAddr;
  33. int fSockfd;
  34. uint fNSubProcess;
  35. int fNetJumpCnt;
  36. bool fRunning;
  37. jack_client_t* fJackClient;
  38. const char* fClientName;
  39. jack_port_t** fAudioCapturePorts;
  40. jack_port_t** fAudioPlaybackPorts;
  41. jack_port_t** fMidiCapturePorts;
  42. jack_port_t** fMidiPlaybackPorts;
  43. packet_header_t fTxHeader;
  44. packet_header_t fRxHeader;
  45. char* fTxBuffer;
  46. char* fRxBuffer;
  47. char* fTxData;
  48. char* fRxData;
  49. NetAudioBuffer* fNetAudioCaptureBuffer;
  50. NetAudioBuffer* fNetAudioPlaybackBuffer;
  51. NetMidiBuffer* fNetMidiCaptureBuffer;
  52. NetMidiBuffer* fNetMidiPlaybackBuffer;
  53. int fAudioTxLen;
  54. int fAudioRxLen;
  55. bool Init();
  56. void FreePorts();
  57. void Exit();
  58. int Send ( char* buffer, size_t size, int flags );
  59. int Recv ( size_t size, int flags );
  60. int Process();
  61. public:
  62. JackNetMaster ( JackNetMasterManager* manager, session_params_t& params, struct sockaddr_in& address, struct sockaddr_in& mcast_addr );
  63. ~JackNetMaster ();
  64. };
  65. typedef std::list<JackNetMaster*> master_list_t;
  66. typedef master_list_t::iterator master_list_it_t;
  67. class JackNetMasterManager
  68. {
  69. private:
  70. static void* NetManagerThread ( void* arg );
  71. static int SetProcess ( jack_nframes_t nframes, void* arg );
  72. jack_client_t* fManagerClient;
  73. const char* fManagerName;
  74. const char* fMCastIP;
  75. int fUDPPort;
  76. pthread_t fManagerThread;
  77. master_list_t fMasterList;
  78. uint32_t fGlobalID;
  79. bool fRunning;
  80. void Run();
  81. JackNetMaster* MasterInit ( session_params_t& params, struct sockaddr_in& address, struct sockaddr_in& mcast_addr );
  82. master_list_it_t FindMaster ( uint32_t client_id );
  83. void KillMaster ( session_params_t* params );
  84. void SetSlaveName ( session_params_t& params );
  85. int Process();
  86. public:
  87. JackNetMasterManager ( jack_client_t* jack_client );
  88. ~JackNetMasterManager();
  89. void Exit();
  90. };
  91. }
  92. #endif