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.

120 lines
4.2KB

  1. /*
  2. Copyright (C) 2004-2006 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef __JackEngine__
  16. #define __JackEngine__
  17. #include "JackConstants.h"
  18. #include "JackGraphManager.h"
  19. #include "JackSynchro.h"
  20. #include "JackTransportEngine.h"
  21. namespace Jack
  22. {
  23. class JackClientInterface;
  24. struct JackEngineControl;
  25. class JackServerNotifyChannelInterface;
  26. class JackEngineTiming;
  27. class JackExternalClient;
  28. class JackSyncInterface;
  29. /*!
  30. \brief Engine description.
  31. */
  32. class JackEngine
  33. {
  34. private:
  35. JackGraphManager* fGraphManager;
  36. JackEngineControl* fEngineControl;
  37. JackClientInterface* fClientTable[CLIENT_NUM];
  38. JackSynchro** fSynchroTable;
  39. JackServerNotifyChannelInterface* fChannel; /*! To communicate between the RT thread and server */
  40. JackEngineTiming* fTiming;
  41. JackSyncInterface* fSignal;
  42. jack_time_t fLastSwitchUsecs;
  43. int ClientCloseAux(int refnum, JackClientInterface* client, bool wait);
  44. void CheckXRun(jack_time_t callback_usecs);
  45. int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum);
  46. void NotifyRemoveClient(const char* name, int refnum);
  47. bool IsZombie(JackClientInterface* client, jack_time_t current_time);
  48. void RemoveZombifiedClients(jack_time_t current_time);
  49. void GetZombifiedClients(bool clients[CLIENT_NUM], jack_time_t current_time);
  50. public:
  51. JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* control, JackSyncInterface* signal, bool sync, long time_out_ms, bool rt, long priority, bool verbose);
  52. virtual ~JackEngine();
  53. int Open();
  54. int Close();
  55. // Client management
  56. bool ClientCheckName(const char* name);
  57. int ClientNew(const char* name, int* refnum, int* shared_engine, int* shared_client, int* shared_graph_manager);
  58. int ClientExternalNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager, JackExternalClient* client);
  59. int ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client);
  60. int ClientClose(int refnum);
  61. int ClientInternalClose(int refnum);
  62. int ClientInternalCloseIm(int refnum);
  63. int ClientActivate(int refnum);
  64. int ClientDeactivate(int refnum);
  65. // Port management
  66. int PortRegister(int refnum, const char* name, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index);
  67. int PortUnRegister(int refnum, jack_port_id_t port);
  68. int PortConnect(int refnum, const char* src, const char* dst);
  69. int PortDisconnect(int refnum, const char* src, const char* dst);
  70. int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
  71. int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
  72. // Transport management
  73. int ReleaseTimebase(int refnum);
  74. int SetTimebaseCallback(int refnum, int conditional);
  75. // Graph
  76. void Process(jack_time_t callback_usecs);
  77. void ZombifyClient(int refnum);
  78. // Notifications
  79. void NotifyClient(int refnum, int event, int sync, int value);
  80. void NotifyClients(int event, int sync, int value);
  81. void NotifyXRun(jack_time_t callback_usecs);
  82. void NotifyXRun(int refnum);
  83. void NotifyGraphReorder();
  84. void NotifyBufferSize(jack_nframes_t nframes);
  85. void NotifyFreewheel(bool onoff);
  86. void NotifyPortRegistation(jack_port_id_t port_index, bool onoff);
  87. void PrintState();
  88. };
  89. } // end of namespace
  90. #endif