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.

117 lines
3.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_engine_h__
  17. #define __jack_engine_h__
  18. #include <jack/jack.h>
  19. #include <jack/internal.h>
  20. struct _jack_driver;
  21. struct _jack_client_internal;
  22. struct _jack_port_internal;
  23. struct _jack_engine {
  24. jack_control_t *control;
  25. struct _jack_driver *driver;
  26. /* these are all "callbacks" made by the driver */
  27. int (*process)(struct _jack_engine *, jack_nframes_t frames);
  28. int (*set_buffer_size)(struct _jack_engine *, jack_nframes_t frames);
  29. int (*set_sample_rate)(struct _jack_engine *, jack_nframes_t frames);
  30. int (*process_lock)(struct _jack_engine *);
  31. void (*process_unlock)(struct _jack_engine *);
  32. int (*post_process)(struct _jack_engine *);
  33. /* "private" sections starts here */
  34. pthread_mutex_t client_lock;
  35. pthread_mutex_t buffer_lock;
  36. pthread_mutex_t port_lock;
  37. int process_errors;
  38. int period_msecs;
  39. int port_max;
  40. int control_shm_id;
  41. key_t control_key;
  42. key_t port_segment_key; /* XXX fix me */
  43. void *port_segment_address; /* XXX fix me */
  44. pthread_t main_thread;
  45. pthread_t server_thread;
  46. /* these lists are protected by `buffer_lock' */
  47. JSList *port_segments;
  48. JSList *port_buffer_freelist;
  49. /* these lists are all protected by `client_lock' */
  50. JSList *clients;
  51. JSList *clients_waiting;
  52. JSList *aliases;
  53. struct _jack_port_internal *internal_ports;
  54. JSList *port_types; /* holds ptrs to jack_port_type_info_t */
  55. int fds[2];
  56. jack_client_id_t next_client_id;
  57. size_t pfd_size;
  58. size_t pfd_max;
  59. struct pollfd *pfd;
  60. struct _jack_client_internal *timebase_client;
  61. jack_port_buffer_info_t *silent_buffer;
  62. char fifo_prefix[PATH_MAX+1];
  63. int *fifo;
  64. unsigned long fifo_size;
  65. unsigned long external_client_cnt;
  66. int rtpriority;
  67. char verbose;
  68. char asio_mode;
  69. int reordered;
  70. int watchdog_check;
  71. float cpu_mhz;
  72. struct _jack_client_internal *current_client;
  73. #define JACK_ENGINE_ROLLING_COUNT 32
  74. #define JACK_ENGINE_ROLLING_INTERVAL 1024
  75. float rolling_client_usecs[JACK_ENGINE_ROLLING_COUNT];
  76. int rolling_client_usecs_cnt;
  77. int rolling_client_usecs_index;
  78. int rolling_interval;
  79. float spare_usecs;
  80. float usecs_per_cycle;
  81. };
  82. /* public functions */
  83. jack_engine_t *jack_engine_new (int real_time, int real_time_priority, int verbose);
  84. int jack_engine_delete (jack_engine_t *);
  85. int jack_run (jack_engine_t *engine);
  86. int jack_wait (jack_engine_t *engine);
  87. int jack_use_driver (jack_engine_t *, struct _jack_driver *);
  88. void jack_set_asio_mode (jack_engine_t *, int yn);
  89. void jack_dump_configuration(jack_engine_t *engine, int take_lock);
  90. #endif /* __jack_engine_h__ */