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.

245 lines
5.8KB

  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. unsigned long port_max;
  68. jack_port_shared_t ports[0];
  69. } jack_control_t;
  70. typedef enum {
  71. BufferSizeChange,
  72. SampleRateChange,
  73. NewPortBufferSegment,
  74. PortConnected,
  75. PortDisconnected,
  76. GraphReordered,
  77. PortRegistered,
  78. PortUnregistered,
  79. } AudioEngineEventType;
  80. typedef struct {
  81. AudioEngineEventType type;
  82. union {
  83. unsigned long n;
  84. jack_port_id_t port_id;
  85. jack_port_id_t self_id;
  86. } x;
  87. union {
  88. unsigned long n;
  89. jack_port_id_t other_id;
  90. } y;
  91. } jack_event_t;
  92. typedef enum {
  93. ClientDynamic, /* connect request just names .so */
  94. ClientDriver, /* code is loaded along with driver */
  95. ClientOutOfProcess /* client is in another process */
  96. } ClientType;
  97. typedef enum {
  98. NotTriggered,
  99. Triggered,
  100. Running,
  101. Finished
  102. } jack_client_state_t;
  103. typedef volatile struct {
  104. volatile nframes_t frame_time; /* w: client r: engine (if client is timebase) */
  105. volatile int id; /* w: engine r: engine and client */
  106. volatile nframes_t nframes; /* w: engine r: client */
  107. volatile jack_client_state_t state; /* w: engine and client r: engine */
  108. volatile char name[JACK_CLIENT_NAME_SIZE+1];
  109. volatile ClientType type; /* w: engine r: engine and client */
  110. volatile char active : 1; /* w: engine r: engine and client */
  111. volatile char dead : 1; /* r/w: engine */
  112. volatile char timed_out : 1; /* r/w: engine */
  113. /* callbacks */
  114. JackProcessCallback process;
  115. void *process_arg;
  116. JackBufferSizeCallback bufsize;
  117. void *bufsize_arg;
  118. JackSampleRateCallback srate;
  119. void *srate_arg;
  120. JackPortRegistrationCallback port_register;
  121. void *port_register_arg;
  122. JackGraphOrderCallback graph_order;
  123. void *graph_order_arg;
  124. /* for engine use only */
  125. void *private_internal_client;
  126. } jack_client_control_t;
  127. typedef struct {
  128. ClientType type;
  129. char name[JACK_CLIENT_NAME_SIZE+1];
  130. char object_path[PATH_MAX+1];
  131. } jack_client_connect_request_t;
  132. typedef struct {
  133. int status;
  134. int client_key;
  135. int control_key;
  136. char fifo_prefix[PATH_MAX+1];
  137. int realtime;
  138. int realtime_priority;
  139. /* these two are valid only if the connect request
  140. was for type == ClientDriver.
  141. */
  142. jack_client_control_t *client_control;
  143. jack_control_t *engine_control;
  144. /* XXX need to be able to use more than one port segment key */
  145. key_t port_segment_key;
  146. } jack_client_connect_result_t;
  147. typedef struct {
  148. jack_client_id_t client_id;
  149. } jack_client_connect_ack_request_t;
  150. typedef struct {
  151. char status;
  152. } jack_client_connect_ack_result_t;
  153. typedef enum {
  154. RegisterPort = 1,
  155. UnRegisterPort = 2,
  156. ConnectPorts = 3,
  157. DisconnectPorts = 4,
  158. SetTimeBaseClient = 5,
  159. ActivateClient = 6,
  160. DeactivateClient = 7,
  161. DisconnectPort = 8
  162. } AudioEngineRequestType;
  163. typedef struct {
  164. AudioEngineRequestType type;
  165. union {
  166. struct {
  167. char name[JACK_PORT_NAME_SIZE+1];
  168. char type[JACK_PORT_TYPE_SIZE+1];
  169. unsigned long flags;
  170. unsigned long buffer_size;
  171. jack_port_id_t port_id;
  172. jack_client_id_t client_id;
  173. } port_info;
  174. struct {
  175. char source_port[JACK_PORT_NAME_SIZE+1];
  176. char destination_port[JACK_PORT_NAME_SIZE+1];
  177. } connect;
  178. jack_client_id_t client_id;
  179. nframes_t nframes;
  180. } x;
  181. int status;
  182. } jack_request_t;
  183. extern void jack_cleanup_shm ();
  184. extern void jack_cleanup_files ();
  185. extern int jack_client_handle_port_connection (jack_client_t *client, jack_event_t *event);
  186. jack_client_t *jack_driver_become_client (const char *client_name);
  187. extern char *jack_temp_dir;
  188. #endif /* __jack_internal_h__ */