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.

126 lines
4.6KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2008 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 __JackGraphManager__
  17. #define __JackGraphManager__
  18. #include "JackShmMem.h"
  19. #include "JackPort.h"
  20. #include "JackConstants.h"
  21. #include "JackConnectionManager.h"
  22. #include "JackAtomicState.h"
  23. namespace Jack
  24. {
  25. /*!
  26. \brief Graph manager: contains the connection manager and the port array.
  27. */
  28. class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectionManager>
  29. {
  30. private:
  31. JackPort fPortArray[PORT_NUM];
  32. JackClientTiming fClientTiming[CLIENT_NUM];
  33. jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  34. void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index);
  35. const char** GetPortsAux(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  36. float* GetBuffer(jack_port_id_t port_index);
  37. void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames);
  38. jack_nframes_t ComputeTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count);
  39. public:
  40. JackGraphManager()
  41. {}
  42. ~JackGraphManager()
  43. {}
  44. void SetBufferSize(jack_nframes_t buffer_size);
  45. // Ports management
  46. jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size);
  47. int ReleasePort(int refnum, jack_port_id_t port_index);
  48. void GetInputPorts(int refnum, jack_int_t* res);
  49. void GetOutputPorts(int refnum, jack_int_t* res);
  50. void RemoveAllPorts(int refnum);
  51. void DisconnectAllPorts(int refnum);
  52. JackPort* GetPort(jack_port_id_t index);
  53. jack_port_id_t GetPort(const char* name);
  54. int ComputeTotalLatency(jack_port_id_t port_index);
  55. int ComputeTotalLatencies();
  56. int RequestMonitor(jack_port_id_t port_index, bool onoff);
  57. // Connections management
  58. int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
  59. int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
  60. int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst);
  61. int GetConnectionsNum(jack_port_id_t port_index);
  62. const char** GetConnections(jack_port_id_t port_index);
  63. void GetConnections(jack_port_id_t port_index, jack_int_t* connections); // TODO
  64. const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  65. int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index);
  66. int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst);
  67. void DisconnectAllInput(jack_port_id_t port_index);
  68. void DisconnectAllOutput(jack_port_id_t port_index);
  69. int DisconnectAll(jack_port_id_t port_index);
  70. bool IsDirectConnection(int ref1, int ref2);
  71. void DirectConnect(int ref1, int ref2);
  72. void DirectDisconnect(int ref1, int ref2);
  73. void Activate(int refnum);
  74. void Deactivate(int refnum);
  75. int GetInputRefNum(jack_port_id_t port_index);
  76. int GetOutputRefNum(jack_port_id_t port_index);
  77. // Buffer management
  78. void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
  79. // Activation management
  80. void RunCurrentGraph();
  81. bool RunNextGraph();
  82. bool IsFinishedGraph();
  83. void InitRefNum(int refnum);
  84. int ResumeRefNum(JackClientControl* control, JackSynchro** table);
  85. int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs);
  86. JackClientTiming* GetClientTiming(int refnum);
  87. void Save(JackConnectionManager* dst);
  88. void Restore(JackConnectionManager* src);
  89. };
  90. } // end of namespace
  91. #endif