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.

125 lines
4.5KB

  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. #include "JackMutex.h"
  24. namespace Jack
  25. {
  26. /*!
  27. \brief Graph manager: contains the connection manager and the port array.
  28. */
  29. class JackGraphManager : public JackShmMem, public JackAtomicState<JackConnectionManager>, public JackLockAble
  30. {
  31. private:
  32. JackPort fPortArray[PORT_NUM];
  33. JackClientTiming fClientTiming[CLIENT_NUM];
  34. jack_nframes_t fBufferSize;
  35. jack_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  36. void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index);
  37. const char** GetPortsAux(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  38. float* GetBuffer(jack_port_id_t port_index);
  39. void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames);
  40. jack_nframes_t GetTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count);
  41. public:
  42. JackGraphManager() : fBufferSize(0)
  43. {}
  44. virtual ~JackGraphManager()
  45. {}
  46. void SetBufferSize(jack_nframes_t buffer_size);
  47. // Ports management
  48. jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  49. int ReleasePort(int refnum, jack_port_id_t port_index);
  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. jack_nframes_t GetTotalLatency(jack_port_id_t port_index);
  55. int RequestMonitor(jack_port_id_t port_index, bool onoff);
  56. // Connections management
  57. int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
  58. int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
  59. int GetConnectionsNum(jack_port_id_t port_index);
  60. int ConnectedTo(jack_port_id_t port_src, const char* port_name);
  61. const char** GetConnections(jack_port_id_t port_index);
  62. const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  63. int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index);
  64. int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst);
  65. int CheckPort(jack_port_id_t port_index);
  66. void DisconnectAllInput(jack_port_id_t port_index);
  67. void DisconnectAllOutput(jack_port_id_t port_index);
  68. int DisconnectAll(jack_port_id_t port_index);
  69. bool IsDirectConnection(int ref1, int ref2);
  70. void DirectConnect(int ref1, int ref2);
  71. void DirectDisconnect(int ref1, int ref2);
  72. void Activate(int refnum);
  73. void Deactivate(int refnum);
  74. int GetInputRefNum(jack_port_id_t port_index);
  75. int GetOutputRefNum(jack_port_id_t port_index);
  76. // Buffer management
  77. void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
  78. // Activation management
  79. void RunCurrentGraph();
  80. bool RunNextGraph();
  81. bool IsFinishedGraph();
  82. void InitRefNum(int refnum);
  83. int ResumeRefNum(JackClientControl* control, JackSynchro** table);
  84. int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs);
  85. JackClientTiming* GetClientTiming(int refnum);
  86. void Save(JackConnectionManager* dst);
  87. void Restore(JackConnectionManager* src);
  88. };
  89. } // end of namespace
  90. #endif