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.

122 lines
4.3KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2006 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, 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 GetTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count);
  39. public:
  40. JackGraphManager()
  41. {}
  42. virtual ~JackGraphManager()
  43. {}
  44. // Ports management
  45. jack_port_id_t AllocatePort(int refnum, const char* port_name, JackPortFlags flags);
  46. void ReleasePort(jack_port_id_t port_index);
  47. JackPort* GetPort(jack_port_id_t index);
  48. jack_port_id_t GetPort(const char* name);
  49. jack_nframes_t GetTotalLatency(jack_port_id_t port_index);
  50. int RequestMonitor(jack_port_id_t port_index, bool onoff);
  51. // Connections management
  52. int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
  53. int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
  54. int GetConnectionsNum(jack_port_id_t port_index);
  55. int ConnectedTo(jack_port_id_t port_src, const char* port_name);
  56. const char** GetConnections(jack_port_id_t port_index);
  57. const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  58. int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index);
  59. int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst);
  60. int CheckPort(jack_port_id_t port_index);
  61. void DisconnectAllInput(jack_port_id_t port_index);
  62. void DisconnectAllOutput(jack_port_id_t port_index);
  63. int DisconnectAll(jack_port_id_t port_index);
  64. // Client management
  65. int AllocateRefNum();
  66. void ReleaseRefNum(int refnum);
  67. bool IsDirectConnection(int ref1, int ref2);
  68. void DirectConnect(int ref1, int ref2);
  69. void DirectDisconnect(int ref1, int ref2);
  70. int RemovePort(int refnum, jack_port_id_t port_index);
  71. void RemoveAllPorts(int refnum);
  72. void DisconnectAllPorts(int refnum);
  73. int GetInputRefNum(jack_port_id_t port_index);
  74. int GetOutputRefNum(jack_port_id_t port_index);
  75. // Buffer management
  76. void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
  77. // Activation management
  78. void RunCurrentGraph();
  79. bool RunNextGraph();
  80. bool IsFinishedGraph();
  81. int ResumeRefNum(JackClientControl* control, JackSynchro** table);
  82. int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs);
  83. JackClientTiming* GetClientTiming(int ref);
  84. void Save(JackConnectionManager* dst);
  85. void Restore(JackConnectionManager* src);
  86. };
  87. } // end of namespace
  88. #endif