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.

220 lines
5.2KB

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