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.

117 lines
3.6KB

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