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.

129 lines
4.4KB

  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 Lesser General Public License as published by
  5. the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. $Id$
  15. */
  16. #ifndef __jack_port_h__
  17. #define __jack_port_h__
  18. #include <pthread.h>
  19. #include <jack/types.h>
  20. #include <jack/jslist.h>
  21. #define JACK_PORT_NAME_SIZE 32
  22. #define JACK_PORT_TYPE_SIZE 32
  23. /* these should probably go somewhere else, but not in <jack/types.h> */
  24. #define JACK_CLIENT_NAME_SIZE 32
  25. typedef uint32_t jack_client_id_t;
  26. typedef struct {
  27. shm_name_t shm_name;
  28. char *address;
  29. size_t size;
  30. } jack_port_segment_info_t;
  31. typedef struct _jack_port_type_info {
  32. uint32_t type_id;
  33. const char type_name[JACK_PORT_TYPE_SIZE];
  34. /* Function to mixdown multiple inputs to a buffer. Can be NULL,
  35. * indicating that multiple input connections are not legal for
  36. * this data type. */
  37. void (*mixdown)(jack_port_t *, jack_nframes_t);
  38. /* Function to compute a peak value for a buffer. Can be NULL,
  39. * indicating that the computation has no meaning. The return
  40. * value is normalized to a [0..1] range. */
  41. double (*peak)(jack_port_t *, jack_nframes_t);
  42. /* Function to compute a power value for a buffer. Can be NULL,
  43. * indicating that the computation has no meaning. The return
  44. * value is normalized to a [0..1] range. */
  45. double (*power)(jack_port_t *, jack_nframes_t);
  46. /* If == 1, then a buffer to handle nframes worth of data has
  47. * sizeof(jack_default_audio_sample_t) * nframes bytes. If
  48. * anything other than 1, the buffer allocated for input mixing
  49. * will be this value times sizeof(jack_default_audio_sample_t) *
  50. * nframes bytes in size. For non-audio data types, it may have a
  51. * different value. If < 0, the value should be ignored, and
  52. * buffer_size should be used. */
  53. int32_t buffer_scale_factor;
  54. /* ignored unless buffer_scale_factor is < 0. see above */
  55. size_t buffer_size;
  56. /* these are all run-time information, controlled by the server */
  57. jack_port_segment_info_t shm_info;
  58. pthread_mutex_t buffer_lock;
  59. JSList *buffer_freelist;
  60. } jack_port_type_info_t;
  61. /* This is the data structure allocated in shared memory
  62. * by the engine.
  63. */
  64. typedef struct _jack_port_shared {
  65. jack_port_type_info_t type_info;
  66. /* location of buffer as an offset from the start of the port's
  67. * type-specific shared memory region. */
  68. size_t offset;
  69. /* index into engine port array for this port */
  70. jack_port_id_t id;
  71. uint32_t flags;
  72. char name[JACK_CLIENT_NAME_SIZE+JACK_PORT_NAME_SIZE+2];
  73. jack_client_id_t client_id; /* who owns me */
  74. volatile jack_nframes_t latency;
  75. volatile jack_nframes_t total_latency;
  76. volatile uint8_t monitor_requests;
  77. char in_use : 1;
  78. char locked : 1;
  79. struct _jack_port *tied;
  80. } jack_port_shared_t;
  81. /* This is the data structure allocated by the client in local
  82. * memory. The `shared' pointer points to the corresponding structure
  83. * in shared memory.
  84. */
  85. struct _jack_port {
  86. char *client_segment_base;
  87. struct _jack_port_shared *shared;
  88. pthread_mutex_t connection_lock;
  89. JSList *connections;
  90. };
  91. /* Inline would be cleaner, but it needs to be fast even in
  92. * non-optimized code. */
  93. #define jack_port_buffer(p) \
  94. ((void *) ((p)->client_segment_base + (p)->shared->offset))
  95. /* This is the structure allocated by the engine in local memory. */
  96. typedef struct _jack_port_internal {
  97. struct _jack_port_shared *shared;
  98. JSList *connections;
  99. void *buffer_info;
  100. } jack_port_internal_t;
  101. #endif /* __jack_port_h__ */