jack2 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.

206 lines
7.3KB

  1. /*
  2. Copyright (C) 2003 Bob Ham <rah@bash.sh>
  3. Copyright (C) 2008 Nedko Arnaudov <nedko@arnaudov.name>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. #ifndef __jack_driver_interface_h__
  17. #define __jack_driver_interface_h__
  18. #ifdef __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. #include <limits.h>
  23. #include "jslist.h"
  24. #include "JackCompilerDeps.h"
  25. #include "JackSystemDeps.h"
  26. #define JACK_DRIVER_NAME_MAX 15
  27. #define JACK_DRIVER_PARAM_NAME_MAX 15
  28. #define JACK_DRIVER_PARAM_STRING_MAX 127
  29. #define JACK_DRIVER_PARAM_DESC 255
  30. #define JACK_PATH_MAX 511
  31. #define JACK_CONSTRAINT_FLAG_RANGE ((uint32_t)1) /**< if set, constraint is a range (min-max) */
  32. #define JACK_CONSTRAINT_FLAG_STRICT ((uint32_t)2) /**< if set, constraint is strict, i.e. supplying non-matching value will not work */
  33. #define JACK_CONSTRAINT_FLAG_FAKE_VALUE ((uint32_t)4) /**< if set, values have no user meaningful meaning */
  34. /** Driver parameter types */
  35. typedef enum
  36. {
  37. JackDriverParamInt = 1,
  38. JackDriverParamUInt,
  39. JackDriverParamChar,
  40. JackDriverParamString,
  41. JackDriverParamBool
  42. } jack_driver_param_type_t;
  43. /** Driver types */
  44. typedef enum
  45. {
  46. JackDriverMaster = 1,
  47. JackDriverSlave,
  48. JackDriverNone,
  49. } jack_driver_type_t;
  50. /** Driver parameter value */
  51. typedef union
  52. {
  53. uint32_t ui;
  54. int32_t i;
  55. char c;
  56. char str[JACK_DRIVER_PARAM_STRING_MAX + 1];
  57. } jack_driver_param_value_t;
  58. typedef struct {
  59. jack_driver_param_value_t value;
  60. char short_desc[64]; /**< A short (~30 chars) description for the user */
  61. } jack_driver_param_value_enum_t;
  62. struct jack_constraint_enum_uint32_descriptor {
  63. uint32_t value;
  64. const char * short_desc;
  65. };
  66. struct jack_constraint_enum_sint32_descriptor {
  67. int32_t value;
  68. const char * short_desc;
  69. };
  70. struct jack_constraint_enum_char_descriptor {
  71. char value;
  72. const char * short_desc;
  73. };
  74. struct jack_constraint_enum_str_descriptor {
  75. const char * value;
  76. const char * short_desc;
  77. };
  78. typedef struct {
  79. uint32_t flags; /**< JACK_CONSTRAINT_FLAG_XXX */
  80. union {
  81. struct {
  82. jack_driver_param_value_t min;
  83. jack_driver_param_value_t max;
  84. } range; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is set */
  85. struct {
  86. uint32_t count;
  87. jack_driver_param_value_enum_t * possible_values_array;
  88. } enumeration; /**< valid when JACK_CONSTRAINT_FLAG_RANGE flag is not set */
  89. } constraint;
  90. } jack_driver_param_constraint_desc_t;
  91. /** A driver parameter descriptor */
  92. typedef struct {
  93. char name[JACK_DRIVER_NAME_MAX + 1]; /**< The parameter's name */
  94. char character; /**< The parameter's character (for getopt, etc) */
  95. jack_driver_param_type_t type; /**< The parameter's type */
  96. jack_driver_param_value_t value; /**< The parameter's (default) value */
  97. jack_driver_param_constraint_desc_t * constraint; /**< Pointer to parameter constraint descriptor. NULL if there is no constraint */
  98. char short_desc[64]; /**< A short (~30 chars) description for the user */
  99. char long_desc[1024]; /**< A longer description for the user */
  100. }
  101. jack_driver_param_desc_t;
  102. /** A driver parameter */
  103. typedef struct {
  104. char character;
  105. jack_driver_param_value_t value;
  106. }
  107. jack_driver_param_t;
  108. /** A struct for describing a jack driver */
  109. typedef struct {
  110. char name[JACK_DRIVER_NAME_MAX + 1]; /**< The driver's canonical name */
  111. jack_driver_type_t type; /**< The driver's type */
  112. char desc[JACK_DRIVER_PARAM_DESC + 1]; /**< The driver's extended description */
  113. #ifdef WIN32
  114. wchar_t file[JACK_PATH_MAX + 1]; /**< The filename of the driver's shared object file */
  115. #else
  116. char file[JACK_PATH_MAX + 1]; /**< The filename of the driver's shared object file */
  117. #endif
  118. uint32_t nparams; /**< The number of parameters the driver has */
  119. jack_driver_param_desc_t * params; /**< An array of parameter descriptors */
  120. }
  121. jack_driver_desc_t;
  122. typedef struct {
  123. uint32_t size; /* size of the param array, in elements */
  124. }
  125. jack_driver_desc_filler_t;
  126. int jack_parse_driver_params(jack_driver_desc_t * desc, int argc, char* argv[], JSList ** param_ptr);
  127. // To be used by drivers
  128. SERVER_EXPORT jack_driver_desc_t * /* Newly allocated driver descriptor, NULL on failure */
  129. jack_driver_descriptor_construct(
  130. const char * name, /* Driver name */
  131. jack_driver_type_t type, /* Driver type */
  132. const char * description, /* Driver description */
  133. jack_driver_desc_filler_t * filler); /* Pointer to stack var to be supplied to jack_driver_descriptor_add_parameter() as well.
  134. Can be NULL for drivers that have no parameters. */
  135. SERVER_EXPORT int /* 0 on failure */
  136. jack_driver_descriptor_add_parameter(
  137. jack_driver_desc_t * driver_descr, /* Pointer to driver descriptor as returned by jack_driver_descriptor_construct() */
  138. jack_driver_desc_filler_t * filler, /* Pointer to the stack var that was supplied to jack_driver_descriptor_add_parameter(). */
  139. const char * name, /* Parameter's name */
  140. char character, /* Parameter's character (for getopt, etc) */
  141. jack_driver_param_type_t type, /* The parameter's type */
  142. const jack_driver_param_value_t * value_ptr, /* Pointer to parameter's (default) value */
  143. jack_driver_param_constraint_desc_t * constraint, /* Pointer to parameter constraint descriptor. NULL if there is no constraint */
  144. const char * short_desc, /* A short (~30 chars) description for the user */
  145. const char * long_desc); /* A longer description for the user, if NULL short_desc will be used */
  146. SERVER_EXPORT
  147. int jack_constraint_add_enum(
  148. jack_driver_param_constraint_desc_t ** constraint_ptr_ptr,
  149. uint32_t * array_size_ptr,
  150. jack_driver_param_value_t * value_ptr,
  151. const char * short_desc);
  152. SERVER_EXPORT
  153. void jack_constraint_free(jack_driver_param_constraint_desc_t * constraint_ptr);
  154. #define JACK_CONSTRAINT_COMPOSE_ENUM(type) \
  155. SERVER_EXPORT \
  156. jack_driver_param_constraint_desc_t * \
  157. jack_constraint_compose_enum_ ## type( \
  158. uint32_t flags, \
  159. struct jack_constraint_enum_ ## type ## _descriptor * descr_array_ptr)
  160. JACK_CONSTRAINT_COMPOSE_ENUM(uint32);
  161. JACK_CONSTRAINT_COMPOSE_ENUM(sint32);
  162. JACK_CONSTRAINT_COMPOSE_ENUM(char);
  163. JACK_CONSTRAINT_COMPOSE_ENUM(str);
  164. typedef jack_driver_desc_t * (*JackDriverDescFunction) ();
  165. #ifdef __cplusplus
  166. }
  167. #endif
  168. #endif /* __jack_driver_interface_h__ */