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.

141 lines
4.7KB

  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 */
  24. #define JACK_CLIENT_NAME_SIZE 32
  25. typedef unsigned long 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. unsigned long type_id;
  33. const char type_name[JACK_PORT_TYPE_SIZE];
  34. void (*mixdown)(jack_port_t *, jack_nframes_t); /* function to mixdown multiple inputs to a buffer. can be
  35. NULL, indicating that multiple input connections
  36. are not legal for this data type.
  37. */
  38. double (*peak)(jack_port_t *, jack_nframes_t); /* function to compute a peak value for a buffer. can be
  39. NULL, indicating that the computation has no meaning.
  40. the return value is normalized to a [0..1] range.
  41. */
  42. double (*power)(jack_port_t *, jack_nframes_t); /* function to compute a power value for a buffer. can be
  43. NULL, indicating that the computation has no meaning.
  44. the return value is normalized to a [0..1] range.
  45. */
  46. long buffer_scale_factor; /* If == 1, then a buffer to handle nframes worth of
  47. data is sizeof(jack_default_audio_sample_t) * nframes bytes large.
  48. If anything other than 1, the buffer allocated
  49. for input mixing will be this value times
  50. sizeof (jack_default_audio_sample_t) * nframes bytes in size.
  51. Obviously, for non-audio data types, it may have
  52. a different value.
  53. if < 0, then the value should be ignored, and
  54. buffer_size should be used.
  55. */
  56. size_t buffer_size; /* ignored unless buffer_scale_factor is < 0. see above */
  57. /* these are all run-time information, controlled by the server */
  58. jack_port_segment_info_t shm_info;
  59. pthread_mutex_t buffer_lock;
  60. JSList *buffer_freelist;
  61. } jack_port_type_info_t;
  62. /* This is the data structure allocated in shared memory
  63. by the engine.
  64. */
  65. typedef struct _jack_port_shared {
  66. jack_port_type_info_t type_info;
  67. size_t offset; // location of buffer as an offset from the
  68. // start of the port's type-specific shared
  69. // memory region.
  70. jack_port_id_t id; // index into engine port array for this port
  71. unsigned long 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 unsigned char 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
  82. in local memory. The `shared' pointer points
  83. the the corresponding structure 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 non-optimized
  92. code.
  93. */
  94. #define jack_port_buffer(p) ((void *) ((p)->client_segment_base + (p)->shared->offset))
  95. /* this is the structure allocated by the engine in local
  96. memory.
  97. */
  98. typedef struct _jack_port_internal {
  99. struct _jack_port_shared *shared;
  100. JSList *connections;
  101. void *buffer_info;
  102. } jack_port_internal_t;
  103. #endif /* __jack_port_h__ */