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.

135 lines
3.9KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2008 Romain Moret at Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __JackNetDriver__
  17. #define __JackNetDriver__
  18. #include "JackAudioDriver.h"
  19. #include "JackNetTool.h"
  20. #ifdef JACK_MONITOR
  21. #include "JackFrameTimer.h"
  22. #endif
  23. namespace Jack
  24. {
  25. class JackNetDriver : public JackAudioDriver
  26. {
  27. private:
  28. session_params_t fParams;
  29. char* fMulticastIP;
  30. JackNetSocket fSocket;
  31. uint fNSubProcess;
  32. net_transport_data_t fTransportData;
  33. //jack ports
  34. jack_port_id_t* fMidiCapturePortList;
  35. jack_port_id_t* fMidiPlaybackPortList;
  36. //headers
  37. packet_header_t fTxHeader;
  38. packet_header_t fRxHeader;
  39. //network buffers
  40. char* fTxBuffer;
  41. char* fRxBuffer;
  42. char* fTxData;
  43. char* fRxData;
  44. //jack buffers
  45. NetMidiBuffer* fNetMidiCaptureBuffer;
  46. NetMidiBuffer* fNetMidiPlaybackBuffer;
  47. NetAudioBuffer* fNetAudioCaptureBuffer;
  48. NetAudioBuffer* fNetAudioPlaybackBuffer;
  49. //sizes
  50. int fAudioRxLen;
  51. int fAudioTxLen;
  52. int fPayloadSize;
  53. //monitoring
  54. #ifdef JACK_MONITOR
  55. static uint fMeasureCnt;
  56. static uint fMeasurePoints;
  57. static uint fMonitorPlotOptionsCnt;
  58. static std::string fMonitorPlotOptions[];
  59. static std::string fMonitorFieldNames[];
  60. float* fMeasure;
  61. int fMeasureId;
  62. JackGnuPlotMonitor<float>* fMonitor;
  63. #endif
  64. bool Init();
  65. net_status_t GetNetMaster();
  66. net_status_t SendMasterStartSync();
  67. void Restart();
  68. int SetParams();
  69. int AllocPorts();
  70. int FreePorts();
  71. JackMidiBuffer* GetMidiInputBuffer ( int port_index );
  72. JackMidiBuffer* GetMidiOutputBuffer ( int port_index );
  73. int Recv ( size_t size, int flags );
  74. int Send ( size_t size, int flags );
  75. int SetSyncPacket();
  76. int TransportSync();
  77. public:
  78. JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table,
  79. const char* ip, int port, int mtu, int midi_input_ports, int midi_output_ports, const char* master_name, uint transport_sync );
  80. ~JackNetDriver();
  81. int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing,
  82. int inchannels, int outchannels, bool monitor, const char* capture_driver_name,
  83. const char* playback_driver_name, jack_nframes_t capture_latency, jack_nframes_t playback_latency );
  84. #ifdef JACK_MONITOR
  85. int Close();
  86. #endif
  87. int Attach();
  88. int Detach();
  89. int Read();
  90. int Write();
  91. // BufferSize can be changed
  92. bool IsFixedBufferSize()
  93. {
  94. return true;
  95. }
  96. int SetBufferSize ( jack_nframes_t buffer_size )
  97. {
  98. return -1;
  99. }
  100. int SetSampleRate ( jack_nframes_t sample_rate )
  101. {
  102. return -1;
  103. }
  104. };
  105. }
  106. #endif