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.

127 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. #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_port_id_t AllocatePortAux(int refnum, const char* port_name, const char* port_type, JackPortFlags flags);
  35. void GetConnectionsAux(JackConnectionManager* manager, const char** res, jack_port_id_t port_index);
  36. const char** GetPortsAux(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  37. float* GetBuffer(jack_port_id_t port_index);
  38. void* GetBufferAux(JackConnectionManager* manager, jack_port_id_t port_index, jack_nframes_t frames);
  39. jack_nframes_t ComputeTotalLatencyAux(jack_port_id_t port_index, jack_port_id_t src_port_index, JackConnectionManager* manager, int hop_count);
  40. public:
  41. JackGraphManager()
  42. {}
  43. ~JackGraphManager()
  44. {}
  45. void SetBufferSize(jack_nframes_t buffer_size);
  46. // Ports management
  47. jack_port_id_t AllocatePort(int refnum, const char* port_name, const char* port_type, JackPortFlags flags, jack_nframes_t buffer_size);
  48. int ReleasePort(int refnum, jack_port_id_t port_index);
  49. void GetInputPorts(int refnum, jack_int_t* res);
  50. void GetOutputPorts(int refnum, jack_int_t* res);
  51. void RemoveAllPorts(int refnum);
  52. void DisconnectAllPorts(int refnum);
  53. JackPort* GetPort(jack_port_id_t index);
  54. jack_port_id_t GetPort(const char* name);
  55. int ComputeTotalLatency(jack_port_id_t port_index);
  56. int ComputeTotalLatencies();
  57. int RequestMonitor(jack_port_id_t port_index, bool onoff);
  58. // Connections management
  59. int Connect(jack_port_id_t src_index, jack_port_id_t dst_index);
  60. int Disconnect(jack_port_id_t src_index, jack_port_id_t dst_index);
  61. int IsConnected(jack_port_id_t port_src, jack_port_id_t port_dst);
  62. int GetConnectionsNum(jack_port_id_t port_index);
  63. const char** GetConnections(jack_port_id_t port_index);
  64. void GetConnections(jack_port_id_t port_index, jack_int_t* connections); // TODO
  65. const char** GetPorts(const char* port_name_pattern, const char* type_name_pattern, unsigned long flags);
  66. int CheckPorts(const char* src, const char* dst, jack_port_id_t* src_index, jack_port_id_t* dst_index);
  67. int CheckPorts(jack_port_id_t port_src, jack_port_id_t port_dst);
  68. void DisconnectAllInput(jack_port_id_t port_index);
  69. void DisconnectAllOutput(jack_port_id_t port_index);
  70. int DisconnectAll(jack_port_id_t port_index);
  71. bool IsDirectConnection(int ref1, int ref2);
  72. void DirectConnect(int ref1, int ref2);
  73. void DirectDisconnect(int ref1, int ref2);
  74. void Activate(int refnum);
  75. void Deactivate(int refnum);
  76. int GetInputRefNum(jack_port_id_t port_index);
  77. int GetOutputRefNum(jack_port_id_t port_index);
  78. // Buffer management
  79. void* GetBuffer(jack_port_id_t port_index, jack_nframes_t frames);
  80. // Activation management
  81. void RunCurrentGraph();
  82. bool RunNextGraph();
  83. bool IsFinishedGraph();
  84. void InitRefNum(int refnum);
  85. int ResumeRefNum(JackClientControl* control, JackSynchro** table);
  86. int SuspendRefNum(JackClientControl* control, JackSynchro** table, long usecs);
  87. JackClientTiming* GetClientTiming(int refnum);
  88. void Save(JackConnectionManager* dst);
  89. void Restore(JackConnectionManager* src);
  90. };
  91. } // end of namespace
  92. #endif