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