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.

238 lines
5.6KB

  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. volatile unsigned long long when_started;
  107. volatile unsigned long long when_done;
  108. /* callbacks */
  109. JackProcessCallback process;
  110. void *process_arg;
  111. JackBufferSizeCallback bufsize;
  112. void *bufsize_arg;
  113. JackSampleRateCallback srate;
  114. void *srate_arg;
  115. JackPortRegistrationCallback port_register;
  116. void *port_register_arg;
  117. /* for engine use only */
  118. void *private_internal_client;
  119. } jack_client_control_t;
  120. typedef struct {
  121. ClientType type;
  122. char name[JACK_CLIENT_NAME_SIZE+1];
  123. char object_path[PATH_MAX+1];
  124. } jack_client_connect_request_t;
  125. typedef struct {
  126. int status;
  127. int client_key;
  128. int control_key;
  129. char fifo_prefix[PATH_MAX+1];
  130. int realtime;
  131. int realtime_priority;
  132. /* these two are valid only if the connect request
  133. was for type == ClientDriver.
  134. */
  135. jack_client_control_t *client_control;
  136. jack_control_t *engine_control;
  137. /* XXX need to be able to use more than one port segment key */
  138. key_t port_segment_key;
  139. } jack_client_connect_result_t;
  140. typedef struct {
  141. jack_client_id_t client_id;
  142. } jack_client_connect_ack_request_t;
  143. typedef struct {
  144. char status;
  145. } jack_client_connect_ack_result_t;
  146. typedef enum {
  147. RegisterPort = 1,
  148. UnRegisterPort = 2,
  149. ConnectPorts = 3,
  150. DisconnectPorts = 4,
  151. SetTimeBaseClient = 5,
  152. ActivateClient = 6,
  153. DeactivateClient = 7,
  154. GetPortTotalLatency = 8,
  155. DisconnectPort = 9
  156. } AudioEngineRequestType;
  157. typedef struct {
  158. AudioEngineRequestType type;
  159. union {
  160. struct {
  161. char name[JACK_PORT_NAME_SIZE+1];
  162. char type[JACK_PORT_TYPE_SIZE+1];
  163. unsigned long flags;
  164. unsigned long buffer_size;
  165. jack_port_id_t port_id;
  166. jack_client_id_t client_id;
  167. } port_info;
  168. struct {
  169. char source_port[JACK_PORT_NAME_SIZE+1];
  170. char destination_port[JACK_PORT_NAME_SIZE+1];
  171. } connect;
  172. jack_client_id_t client_id;
  173. nframes_t nframes;
  174. } x;
  175. int status;
  176. } jack_request_t;
  177. extern void jack_cleanup_shm ();
  178. extern void jack_cleanup_files ();
  179. extern int jack_client_handle_port_connection (jack_client_t *client, jack_event_t *event);
  180. jack_client_t *jack_driver_become_client (const char *client_name);
  181. extern char *jack_temp_dir;
  182. #endif /* __jack_internal_h__ */