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.

128 lines
3.5KB

  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. namespace Jack
  21. {
  22. class JackNetDriver : public JackAudioDriver
  23. {
  24. private:
  25. session_params_t fParams;
  26. char* fMulticastIP;
  27. JackNetSocket fSocket;
  28. uint fNSubProcess;
  29. net_transport_data_t fTransportData;
  30. //jack ports
  31. jack_port_id_t* fMidiCapturePortList;
  32. jack_port_id_t* fMidiPlaybackPortList;
  33. //headers
  34. packet_header_t fTxHeader;
  35. packet_header_t fRxHeader;
  36. //network buffers
  37. char* fTxBuffer;
  38. char* fRxBuffer;
  39. char* fTxData;
  40. char* fRxData;
  41. //jack buffers
  42. NetMidiBuffer* fNetMidiCaptureBuffer;
  43. NetMidiBuffer* fNetMidiPlaybackBuffer;
  44. NetAudioBuffer* fNetAudioCaptureBuffer;
  45. NetAudioBuffer* fNetAudioPlaybackBuffer;
  46. //sizes
  47. int fAudioRxLen;
  48. int fAudioTxLen;
  49. int fPayloadSize;
  50. //monitoring
  51. #ifdef JACK_MONITOR
  52. static std::string fMonitorPlotOptions[];
  53. static std::string fMonitorFieldNames[];
  54. jack_time_t fUsecCycleStart;
  55. NetMeasure<jack_time_t> fMeasure;
  56. NetMonitor<jack_time_t> fMonitor;
  57. #endif
  58. bool Init();
  59. net_status_t GetNetMaster();
  60. net_status_t SendMasterStartSync();
  61. void Restart();
  62. int SetParams();
  63. int AllocPorts();
  64. int FreePorts();
  65. JackMidiBuffer* GetMidiInputBuffer ( int port_index );
  66. JackMidiBuffer* GetMidiOutputBuffer ( int port_index );
  67. int Recv ( size_t size, int flags );
  68. int Send ( size_t size, int flags );
  69. int SetSyncPacket();
  70. int TransportSync();
  71. public:
  72. JackNetDriver ( const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table,
  73. const char* ip, int port, int mtu, int midi_input_ports, int midi_output_ports, const char* master_name, uint transport_sync );
  74. ~JackNetDriver();
  75. int Open ( jack_nframes_t frames_per_cycle, jack_nframes_t rate, bool capturing, bool playing,
  76. int inchannels, int outchannels, bool monitor, const char* capture_driver_name,
  77. const char* playback_driver_name, jack_nframes_t capture_latency, jack_nframes_t playback_latency );
  78. #ifdef JACK_MONITOR
  79. int Close();
  80. #endif
  81. int Attach();
  82. int Detach();
  83. int Read();
  84. int Write();
  85. // BufferSize can be changed
  86. bool IsFixedBufferSize()
  87. {
  88. return true;
  89. }
  90. int SetBufferSize(jack_nframes_t buffer_size)
  91. {
  92. return -1;
  93. }
  94. int SetSampleRate(jack_nframes_t sample_rate)
  95. {
  96. return -1;
  97. }
  98. };
  99. }
  100. #endif