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.

115 lines
2.8KB

  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. JackNetSocket fSocket;
  32. uint fNSubProcess;
  33. int fNetJumpCnt;
  34. bool fRunning;
  35. jack_client_t* fJackClient;
  36. const char* fClientName;
  37. jack_port_t** fAudioCapturePorts;
  38. jack_port_t** fAudioPlaybackPorts;
  39. jack_port_t** fMidiCapturePorts;
  40. jack_port_t** fMidiPlaybackPorts;
  41. packet_header_t fTxHeader;
  42. packet_header_t fRxHeader;
  43. char* fTxBuffer;
  44. char* fRxBuffer;
  45. char* fTxData;
  46. char* fRxData;
  47. NetAudioBuffer* fNetAudioCaptureBuffer;
  48. NetAudioBuffer* fNetAudioPlaybackBuffer;
  49. NetMidiBuffer* fNetMidiCaptureBuffer;
  50. NetMidiBuffer* fNetMidiPlaybackBuffer;
  51. int fAudioTxLen;
  52. int fAudioRxLen;
  53. bool Init();
  54. void FreePorts();
  55. void Exit();
  56. int Send ( char* buffer, size_t size, int flags );
  57. int Recv ( size_t size, int flags );
  58. int Process();
  59. public:
  60. JackNetMaster ( JackNetMasterManager* manager, session_params_t& params );
  61. ~JackNetMaster ();
  62. };
  63. typedef std::list<JackNetMaster*> master_list_t;
  64. typedef master_list_t::iterator master_list_it_t;
  65. class JackNetMasterManager
  66. {
  67. friend class JackNetMaster;
  68. private:
  69. static void* NetManagerThread ( void* arg );
  70. static int SetProcess ( jack_nframes_t nframes, void* arg );
  71. jack_client_t* fManagerClient;
  72. const char* fManagerName;
  73. const char* fMulticastIP;
  74. JackNetSocket fSocket;
  75. pthread_t fManagerThread;
  76. master_list_t fMasterList;
  77. uint32_t fGlobalID;
  78. bool fRunning;
  79. void Run();
  80. JackNetMaster* MasterInit ( session_params_t& params );
  81. master_list_it_t FindMaster ( uint32_t client_id );
  82. void KillMaster ( session_params_t* params );
  83. void SetSlaveName ( session_params_t& params );
  84. int Process();
  85. public:
  86. JackNetMasterManager ( jack_client_t* jack_client );
  87. ~JackNetMasterManager();
  88. void Exit();
  89. };
  90. }
  91. #endif