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.

156 lines
5.7KB

  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 Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #ifndef __JackDebugClient__
  16. #define __JackDebugClient__
  17. #define MAX_PORT_HISTORY 2048
  18. #include "JackClient.h"
  19. #include <list>
  20. #include <fstream>
  21. namespace Jack
  22. {
  23. /*!
  24. \brief Follow a single port.
  25. */
  26. typedef struct
  27. {
  28. jack_port_id_t idport;
  29. char name[JACK_PORT_NAME_SIZE]; //portname
  30. int IsConnected;
  31. int IsUnregistered;
  32. }
  33. PortFollower;
  34. /*!
  35. \brief A "decorator" debug client to validate API use.
  36. */
  37. class JackDebugClient : public JackClient
  38. {
  39. protected:
  40. JackClient* fClient;
  41. std::ofstream* fStream;
  42. PortFollower fPortList[MAX_PORT_HISTORY]; // Arbitrary value... To be tuned...
  43. int fTotalPortNumber; // The total number of port opened and maybe closed. Historical view.
  44. int fOpenPortNumber; // The current number of opened port.
  45. int fIsActivated;
  46. int fIsDeactivated;
  47. int fIsClosed;
  48. bool fFreewheel;
  49. char fClientName[JACK_CLIENT_NAME_SIZE+1];
  50. JackProcessCallback fProcessTimeCallback;
  51. void* fProcessTimeCallbackArg;
  52. public:
  53. JackDebugClient(JackClient* fTheClient);
  54. virtual ~JackDebugClient();
  55. virtual int Open(const char* server_name, const char* name, jack_uuid_t uuid, jack_options_t options, jack_status_t* status);
  56. int Close();
  57. virtual JackGraphManager* GetGraphManager() const;
  58. virtual JackEngineControl* GetEngineControl() const;
  59. // Notifications
  60. int ClientNotify(int refnum, const char* name, int notify, int sync, const char* message, int value1, int value2);
  61. int Activate();
  62. int Deactivate();
  63. // Context
  64. int SetBufferSize(jack_nframes_t buffer_size);
  65. int SetFreeWheel(int onoff);
  66. int ComputeTotalLatencies();
  67. void ShutDown(jack_status_t code, const char* message);
  68. jack_native_thread_t GetThreadID();
  69. // Port management
  70. int PortRegister(const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
  71. int PortUnRegister(jack_port_id_t port);
  72. int PortConnect(const char* src, const char* dst);
  73. int PortDisconnect(const char* src, const char* dst);
  74. int PortDisconnect(jack_port_id_t src);
  75. int PortIsMine(jack_port_id_t port_index);
  76. int PortRename(jack_port_id_t port_index, const char* name);
  77. // Transport
  78. int ReleaseTimebase();
  79. int SetSyncCallback(JackSyncCallback sync_callback, void* arg);
  80. int SetSyncTimeout(jack_time_t timeout);
  81. int SetTimebaseCallback(int conditional, JackTimebaseCallback timebase_callback, void* arg);
  82. void TransportLocate(jack_nframes_t frame);
  83. jack_transport_state_t TransportQuery(jack_position_t* pos);
  84. jack_nframes_t GetCurrentTransportFrame();
  85. int TransportReposition(const jack_position_t* pos);
  86. void TransportStart();
  87. void TransportStop();
  88. // Callbacks
  89. void OnShutdown(JackShutdownCallback callback, void *arg);
  90. void OnInfoShutdown(JackInfoShutdownCallback callback, void *arg);
  91. int SetProcessCallback(JackProcessCallback callback, void* arg);
  92. int SetXRunCallback(JackXRunCallback callback, void* arg);
  93. int SetInitCallback(JackThreadInitCallback callback, void* arg);
  94. int SetGraphOrderCallback(JackGraphOrderCallback callback, void* arg);
  95. int SetBufferSizeCallback(JackBufferSizeCallback callback, void* arg);
  96. int SetClientRegistrationCallback(JackClientRegistrationCallback callback, void* arg);
  97. int SetFreewheelCallback(JackFreewheelCallback callback, void* arg);
  98. int SetPortRegistrationCallback(JackPortRegistrationCallback callback, void* arg);
  99. int SetPortConnectCallback(JackPortConnectCallback callback, void *arg);
  100. int SetPortRenameCallback(JackPortRenameCallback callback, void *arg);
  101. int SetSessionCallback(JackSessionCallback callback, void *arg);
  102. int SetLatencyCallback(JackLatencyCallback callback, void *arg);
  103. // Internal clients
  104. char* GetInternalClientName(int ref);
  105. int InternalClientHandle(const char* client_name, jack_status_t* status);
  106. int InternalClientLoad(const char* client_name, jack_options_t options, jack_status_t* status, jack_varargs_t* va);
  107. void InternalClientUnload(int ref, jack_status_t* status);
  108. // RT Thread
  109. int SetProcessThread(JackThreadCallback fun, void *arg);
  110. // Session API
  111. jack_session_command_t* SessionNotify(const char* target, jack_session_event_type_t type, const char* path);
  112. int SessionReply(jack_session_event_t* ev);
  113. char* GetUUIDForClientName(const char* client_name);
  114. char* GetClientNameByUUID(const char* uuid);
  115. int ReserveClientName(const char* client_name, const char* uuid);
  116. int ClientHasSessionCallback(const char* client_name);
  117. JackClientControl* GetClientControl() const;
  118. void CheckClient(const char* function_name) const;
  119. static int TimeCallback(jack_nframes_t nframes, void *arg);
  120. };
  121. } // end of namespace
  122. #endif