jack1 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.

236 lines
5.5KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  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. $Id$
  15. */
  16. #ifndef __jack_internal_h__
  17. #define __jack_internal_h__
  18. #include <stdlib.h>
  19. #include <unistd.h>
  20. #include <limits.h>
  21. #include <dlfcn.h>
  22. #include <sys/types.h>
  23. #include <sys/time.h>
  24. #include <pthread.h>
  25. #include <glib.h>
  26. #include <jack/jack.h>
  27. #include <jack/types.h>
  28. #include <jack/port.h>
  29. typedef void * dlhandle;
  30. typedef struct {
  31. int shm_key;
  32. size_t offset;
  33. } jack_port_buffer_info_t;
  34. typedef struct {
  35. int shm_key;
  36. char *address;
  37. } jack_port_segment_info_t;
  38. typedef struct _time_info
  39. {
  40. nframes_t frame;
  41. nframes_t frame_rate;
  42. unsigned long microseconds;
  43. double ppqPos; // 1 ppq
  44. double tempo; // in bpm
  45. double barStartPos; // last bar start, in 1 ppq
  46. double cycleStartPos; // 1 ppq
  47. double cycleEndPos; // 1 ppq
  48. float timeSigNumerator; // time signature
  49. float timeSigDenominator;
  50. long smpteOffset;
  51. long smpteFrameRate; // 0:24, 1:25, 2:29.97, 3:30, 4:29.97 df, 5:30 df
  52. long samplesToNextClock; // midi clock resolution (24 ppq), can be negative
  53. long flags; // see below
  54. } time_info;
  55. typedef struct {
  56. time_info time;
  57. pid_t engine_pid;
  58. unsigned long buffer_size;
  59. char real_time;
  60. int client_priority;
  61. unsigned long port_max;
  62. jack_port_shared_t ports[0];
  63. } jack_control_t;
  64. typedef enum {
  65. BufferSizeChange,
  66. SampleRateChange,
  67. NewPortBufferSegment,
  68. PortConnected,
  69. PortDisconnected,
  70. GraphReordered,
  71. PortRegistered,
  72. PortUnregistered,
  73. } AudioEngineEventType;
  74. typedef struct {
  75. AudioEngineEventType type;
  76. union {
  77. unsigned long n;
  78. jack_port_id_t port_id;
  79. jack_port_id_t self_id;
  80. } x;
  81. union {
  82. unsigned long n;
  83. jack_port_id_t other_id;
  84. } y;
  85. } jack_event_t;
  86. typedef enum {
  87. ClientDynamic, /* connect request just names .so */
  88. ClientDriver, /* code is loaded along with driver */
  89. ClientOutOfProcess /* client is in another process */
  90. } ClientType;
  91. typedef enum {
  92. NotTriggered,
  93. Triggered,
  94. Running,
  95. Finished
  96. } jack_client_state_t;
  97. typedef volatile struct {
  98. volatile nframes_t frame_time; /* w: client r: engine (if client is timebase) */
  99. volatile int id; /* w: engine r: engine and client */
  100. volatile nframes_t nframes; /* w: engine r: client */
  101. volatile jack_client_state_t state; /* w: engine and client r: engine */
  102. volatile char name[JACK_CLIENT_NAME_SIZE+1];
  103. volatile ClientType type; /* w: engine r: engine and client */
  104. volatile char active : 1; /* w: engine r: engine and client */
  105. volatile char dead : 1; /* r/w: engine */
  106. /* callbacks */
  107. JackProcessCallback process;
  108. void *process_arg;
  109. JackBufferSizeCallback bufsize;
  110. void *bufsize_arg;
  111. JackSampleRateCallback srate;
  112. void *srate_arg;
  113. JackPortRegistrationCallback port_register;
  114. void *port_register_arg;
  115. /* for engine use only */
  116. void *private_internal_client;
  117. } jack_client_control_t;
  118. typedef struct {
  119. ClientType type;
  120. char name[JACK_CLIENT_NAME_SIZE+1];
  121. char object_path[PATH_MAX+1];
  122. } jack_client_connect_request_t;
  123. typedef struct {
  124. int status;
  125. int client_key;
  126. int control_key;
  127. char fifo_prefix[PATH_MAX+1];
  128. int realtime;
  129. int realtime_priority;
  130. /* these two are valid only if the connect request
  131. was for type == ClientDriver.
  132. */
  133. jack_client_control_t *client_control;
  134. jack_control_t *engine_control;
  135. /* XXX need to be able to use more than one port segment key */
  136. key_t port_segment_key;
  137. } jack_client_connect_result_t;
  138. typedef struct {
  139. jack_client_id_t client_id;
  140. } jack_client_connect_ack_request_t;
  141. typedef struct {
  142. char status;
  143. } jack_client_connect_ack_result_t;
  144. typedef enum {
  145. RegisterPort = 1,
  146. UnRegisterPort = 2,
  147. ConnectPorts = 3,
  148. DisconnectPorts = 4,
  149. SetTimeBaseClient = 5,
  150. ActivateClient = 6,
  151. DeactivateClient = 7,
  152. GetPortTotalLatency = 8,
  153. DisconnectPort = 9
  154. } AudioEngineRequestType;
  155. typedef struct {
  156. AudioEngineRequestType type;
  157. union {
  158. struct {
  159. char name[JACK_PORT_NAME_SIZE+1];
  160. char type[JACK_PORT_TYPE_SIZE+1];
  161. unsigned long flags;
  162. unsigned long buffer_size;
  163. jack_port_id_t port_id;
  164. jack_client_id_t client_id;
  165. } port_info;
  166. struct {
  167. char source_port[JACK_PORT_NAME_SIZE+1];
  168. char destination_port[JACK_PORT_NAME_SIZE+1];
  169. } connect;
  170. jack_client_id_t client_id;
  171. nframes_t nframes;
  172. } x;
  173. int status;
  174. } jack_request_t;
  175. extern void jack_cleanup_shm ();
  176. extern void jack_cleanup_files ();
  177. extern int jack_client_handle_port_connection (jack_client_t *client, jack_event_t *event);
  178. jack_client_t *jack_driver_become_client (const char *client_name);
  179. extern char *jack_temp_dir;
  180. #endif /* __jack_internal_h__ */