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.

129 lines
4.5KB

  1. /*
  2. Copyright (C) 2004-2008 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. #include "JackPlatformPlug.h"
  22. namespace Jack
  23. {
  24. class JackClientInterface;
  25. struct JackEngineControl;
  26. class JackExternalClient;
  27. /*!
  28. \brief Engine description.
  29. */
  30. class SERVER_EXPORT JackEngine
  31. {
  32. private:
  33. JackGraphManager* fGraphManager;
  34. JackEngineControl* fEngineControl;
  35. JackClientInterface* fClientTable[CLIENT_NUM];
  36. JackSynchro* fSynchroTable;
  37. JackServerNotifyChannel fChannel; /*! To communicate between the RT thread and server */
  38. JackProcessSync fSignal;
  39. jack_time_t fLastSwitchUsecs;
  40. int ClientCloseAux(int refnum, JackClientInterface* client, bool wait);
  41. void CheckXRun(jack_time_t callback_usecs);
  42. int NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum);
  43. void NotifyRemoveClient(const char* name, int refnum);
  44. void ProcessNext(jack_time_t callback_usecs);
  45. void ProcessCurrent(jack_time_t callback_usecs);
  46. bool ClientCheckName(const char* name);
  47. bool GenerateUniqueName(char* name);
  48. int AllocateRefnum();
  49. void ReleaseRefnum(int ref);
  50. void NotifyClient(int refnum, int event, int sync, int value1, int value2);
  51. void NotifyClients(int event, int sync, int value1, int value2);
  52. void NotifyPortRegistation(jack_port_id_t port_index, bool onoff);
  53. void NotifyPortConnect(jack_port_id_t src, jack_port_id_t dst, bool onoff);
  54. void NotifyPortRename(jack_port_id_t src);
  55. void NotifyActivate(int refnum);
  56. public:
  57. JackEngine(JackGraphManager* manager, JackSynchro* table, JackEngineControl* controler);
  58. ~JackEngine();
  59. int Open();
  60. int Close();
  61. // Client management
  62. int ClientCheck(const char* name, char* name_res, int protocol, int options, int* status);
  63. int ClientExternalOpen(const char* name, int pid, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager);
  64. int ClientInternalOpen(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client, bool wait);
  65. int ClientExternalClose(int refnum);
  66. int ClientInternalClose(int refnum, bool wait);
  67. int ClientActivate(int refnum, bool state);
  68. int ClientDeactivate(int refnum);
  69. int GetClientPID(const char* name);
  70. // Internal client management
  71. int GetInternalClientName(int int_ref, char* name_res);
  72. int InternalClientHandle(const char* client_name, int* status, int* int_ref);
  73. int InternalClientUnload(int refnum, int* status);
  74. // Port management
  75. int PortRegister(int refnum, const char* name, const char *type, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port);
  76. int PortUnRegister(int refnum, jack_port_id_t port);
  77. int PortConnect(int refnum, const char* src, const char* dst);
  78. int PortDisconnect(int refnum, const char* src, const char* dst);
  79. int PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
  80. int PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst);
  81. int PortRename(int refnum, jack_port_id_t port, const char* name);
  82. // Graph
  83. bool Process(jack_time_t cur_cycle_begin, jack_time_t prev_cycle_end);
  84. // Notifications
  85. void NotifyXRun(jack_time_t callback_usecs, float delayed_usecs);
  86. void NotifyXRun(int refnum);
  87. void NotifyGraphReorder();
  88. void NotifyBufferSize(jack_nframes_t buffer_size);
  89. void NotifySampleRate(jack_nframes_t sample_rate);
  90. void NotifyFreewheel(bool onoff);
  91. };
  92. } // end of namespace
  93. #endif