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.

139 lines
4.0KB

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