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.

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