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.

253 lines
6.0KB

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