Jack2 1.9.12

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