1 | /** |
2 | * \file include/seq.h |
3 | * \brief Application interface library for the ALSA driver |
4 | * \author Jaroslav Kysela <perex@perex.cz> |
5 | * \author Abramo Bagnara <abramo@alsa-project.org> |
6 | * \author Takashi Iwai <tiwai@suse.de> |
7 | * \date 1998-2001 |
8 | */ |
9 | /* |
10 | * Application interface library for the ALSA driver |
11 | * |
12 | * |
13 | * This library is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU Lesser General Public License as |
15 | * published by the Free Software Foundation; either version 2.1 of |
16 | * the License, or (at your option) any later version. |
17 | * |
18 | * This program is distributed in the hope that it will be useful, |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
21 | * GNU Lesser General Public License for more details. |
22 | * |
23 | * You should have received a copy of the GNU Lesser General Public |
24 | * License along with this library; if not, write to the Free Software |
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 | * |
27 | */ |
28 | |
29 | #ifndef __ALSA_SEQ_H |
30 | #define __ALSA_SEQ_H |
31 | |
32 | #ifdef __cplusplus |
33 | extern "C" { |
34 | #endif |
35 | |
36 | /** |
37 | * \defgroup Sequencer MIDI Sequencer |
38 | * MIDI Sequencer Interface. |
39 | * See \ref seq page for more details. |
40 | * \{ |
41 | */ |
42 | |
43 | /** dlsym version for interface entry callback */ |
44 | #define SND_SEQ_DLSYM_VERSION _dlsym_seq_001 |
45 | |
46 | /** Sequencer handle */ |
47 | typedef struct _snd_seq snd_seq_t; |
48 | |
49 | /** |
50 | * sequencer opening stream types |
51 | */ |
52 | #define SND_SEQ_OPEN_OUTPUT 1 /**< open for output (write) */ |
53 | #define SND_SEQ_OPEN_INPUT 2 /**< open for input (read) */ |
54 | #define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT) /**< open for both input and output (read/write) */ |
55 | |
56 | /** |
57 | * sequencer opening mode |
58 | */ |
59 | #define SND_SEQ_NONBLOCK 0x0001 /**< non-blocking mode (flag to open mode) */ |
60 | |
61 | /** sequencer handle type */ |
62 | typedef enum _snd_seq_type { |
63 | SND_SEQ_TYPE_HW, /**< hardware */ |
64 | SND_SEQ_TYPE_SHM, /**< shared memory (NYI) */ |
65 | SND_SEQ_TYPE_INET /**< network (NYI) */ |
66 | } snd_seq_type_t; |
67 | |
68 | /** special client (port) ids */ |
69 | #define SND_SEQ_ADDRESS_UNKNOWN 253 /**< unknown source */ |
70 | #define SND_SEQ_ADDRESS_SUBSCRIBERS 254 /**< send event to all subscribed ports */ |
71 | #define SND_SEQ_ADDRESS_BROADCAST 255 /**< send event to all queues/clients/ports/channels */ |
72 | |
73 | /** known client numbers */ |
74 | #define SND_SEQ_CLIENT_SYSTEM 0 /**< system client */ |
75 | |
76 | /* |
77 | */ |
78 | int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode); |
79 | int snd_seq_open_lconf(snd_seq_t **handle, const char *name, int streams, int mode, snd_config_t *lconf); |
80 | const char *snd_seq_name(snd_seq_t *seq); |
81 | snd_seq_type_t snd_seq_type(snd_seq_t *seq); |
82 | int snd_seq_close(snd_seq_t *handle); |
83 | int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events); |
84 | int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events); |
85 | int snd_seq_poll_descriptors_revents(snd_seq_t *seq, struct pollfd *pfds, unsigned int nfds, unsigned short *revents); |
86 | int snd_seq_nonblock(snd_seq_t *handle, int nonblock); |
87 | int snd_seq_client_id(snd_seq_t *handle); |
88 | |
89 | size_t snd_seq_get_output_buffer_size(snd_seq_t *handle); |
90 | size_t snd_seq_get_input_buffer_size(snd_seq_t *handle); |
91 | int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size); |
92 | int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size); |
93 | |
94 | /** system information container */ |
95 | typedef struct _snd_seq_system_info snd_seq_system_info_t; |
96 | |
97 | size_t snd_seq_system_info_sizeof(void); |
98 | /** allocate a #snd_seq_system_info_t container on stack */ |
99 | #define snd_seq_system_info_alloca(ptr) \ |
100 | __snd_alloca(ptr, snd_seq_system_info) |
101 | int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr); |
102 | void snd_seq_system_info_free(snd_seq_system_info_t *ptr); |
103 | void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src); |
104 | |
105 | int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info); |
106 | int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info); |
107 | int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info); |
108 | int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info); |
109 | int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info); |
110 | int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info); |
111 | |
112 | int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info); |
113 | |
114 | /** \} */ |
115 | |
116 | |
117 | /** |
118 | * \defgroup SeqClient Sequencer Client Interface |
119 | * Sequencer Client Interface |
120 | * \ingroup Sequencer |
121 | * \{ |
122 | */ |
123 | |
124 | /** client information container */ |
125 | typedef struct _snd_seq_client_info snd_seq_client_info_t; |
126 | |
127 | /** client types */ |
128 | typedef enum snd_seq_client_type { |
129 | SND_SEQ_USER_CLIENT = 1, /**< user client */ |
130 | SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */ |
131 | } snd_seq_client_type_t; |
132 | |
133 | size_t snd_seq_client_info_sizeof(void); |
134 | /** allocate a #snd_seq_client_info_t container on stack */ |
135 | #define snd_seq_client_info_alloca(ptr) \ |
136 | __snd_alloca(ptr, snd_seq_client_info) |
137 | int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr); |
138 | void snd_seq_client_info_free(snd_seq_client_info_t *ptr); |
139 | void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src); |
140 | |
141 | int snd_seq_client_info_get_client(const snd_seq_client_info_t *info); |
142 | snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info); |
143 | const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info); |
144 | int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info); |
145 | int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info); |
146 | const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info); |
147 | int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info); |
148 | int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info); |
149 | |
150 | void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client); |
151 | void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name); |
152 | void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val); |
153 | void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val); |
154 | void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter); |
155 | |
156 | void snd_seq_client_info_event_filter_clear(snd_seq_client_info_t *info); |
157 | void snd_seq_client_info_event_filter_add(snd_seq_client_info_t *info, int event_type); |
158 | void snd_seq_client_info_event_filter_del(snd_seq_client_info_t *info, int event_type); |
159 | int snd_seq_client_info_event_filter_check(snd_seq_client_info_t *info, int event_type); |
160 | |
161 | int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info); |
162 | int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info); |
163 | int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info); |
164 | int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info); |
165 | |
166 | /* |
167 | */ |
168 | |
169 | /** client pool information container */ |
170 | typedef struct _snd_seq_client_pool snd_seq_client_pool_t; |
171 | |
172 | size_t snd_seq_client_pool_sizeof(void); |
173 | /** allocate a #snd_seq_client_pool_t container on stack */ |
174 | #define snd_seq_client_pool_alloca(ptr) \ |
175 | __snd_alloca(ptr, snd_seq_client_pool) |
176 | int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr); |
177 | void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr); |
178 | void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src); |
179 | |
180 | int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info); |
181 | size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info); |
182 | size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info); |
183 | size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info); |
184 | size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info); |
185 | size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info); |
186 | void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size); |
187 | void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size); |
188 | void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size); |
189 | |
190 | int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info); |
191 | int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info); |
192 | |
193 | |
194 | /** \} */ |
195 | |
196 | |
197 | /** |
198 | * \defgroup SeqPort Sequencer Port Interface |
199 | * Sequencer Port Interface |
200 | * \ingroup Sequencer |
201 | * \{ |
202 | */ |
203 | |
204 | /** port information container */ |
205 | typedef struct _snd_seq_port_info snd_seq_port_info_t; |
206 | |
207 | /** known port numbers */ |
208 | #define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */ |
209 | #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< system announce port */ |
210 | |
211 | /** port capabilities (32 bits) */ |
212 | #define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */ |
213 | #define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */ |
214 | |
215 | #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */ |
216 | #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */ |
217 | |
218 | #define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */ |
219 | |
220 | #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */ |
221 | #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */ |
222 | #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */ |
223 | |
224 | /* port type */ |
225 | /** Messages sent from/to this port have device-specific semantics. */ |
226 | #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) |
227 | /** This port understands MIDI messages. */ |
228 | #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) |
229 | /** This port is compatible with the General MIDI specification. */ |
230 | #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) |
231 | /** This port is compatible with the Roland GS standard. */ |
232 | #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) |
233 | /** This port is compatible with the Yamaha XG specification. */ |
234 | #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) |
235 | /** This port is compatible with the Roland MT-32. */ |
236 | #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) |
237 | /** This port is compatible with the General MIDI 2 specification. */ |
238 | #define SND_SEQ_PORT_TYPE_MIDI_GM2 (1<<6) |
239 | /** This port understands SND_SEQ_EVENT_SAMPLE_xxx messages |
240 | (these are not MIDI messages). */ |
241 | #define SND_SEQ_PORT_TYPE_SYNTH (1<<10) |
242 | /** Instruments can be downloaded to this port |
243 | (with SND_SEQ_EVENT_INSTR_xxx messages sent directly). */ |
244 | #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) |
245 | /** Instruments can be downloaded to this port |
246 | (with SND_SEQ_EVENT_INSTR_xxx messages sent directly or through a queue). */ |
247 | #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) |
248 | /** This port is implemented in hardware. */ |
249 | #define SND_SEQ_PORT_TYPE_HARDWARE (1<<16) |
250 | /** This port is implemented in software. */ |
251 | #define SND_SEQ_PORT_TYPE_SOFTWARE (1<<17) |
252 | /** Messages sent to this port will generate sounds. */ |
253 | #define SND_SEQ_PORT_TYPE_SYNTHESIZER (1<<18) |
254 | /** This port may connect to other devices |
255 | (whose characteristics are not known). */ |
256 | #define SND_SEQ_PORT_TYPE_PORT (1<<19) |
257 | /** This port belongs to an application, such as a sequencer or editor. */ |
258 | #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) |
259 | |
260 | |
261 | size_t snd_seq_port_info_sizeof(void); |
262 | /** allocate a #snd_seq_port_info_t container on stack */ |
263 | #define snd_seq_port_info_alloca(ptr) \ |
264 | __snd_alloca(ptr, snd_seq_port_info) |
265 | int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr); |
266 | void snd_seq_port_info_free(snd_seq_port_info_t *ptr); |
267 | void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src); |
268 | |
269 | int snd_seq_port_info_get_client(const snd_seq_port_info_t *info); |
270 | int snd_seq_port_info_get_port(const snd_seq_port_info_t *info); |
271 | const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info); |
272 | const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info); |
273 | unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info); |
274 | unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info); |
275 | int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info); |
276 | int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info); |
277 | int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info); |
278 | int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info); |
279 | int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info); |
280 | int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info); |
281 | int snd_seq_port_info_get_timestamping(const snd_seq_port_info_t *info); |
282 | int snd_seq_port_info_get_timestamp_real(const snd_seq_port_info_t *info); |
283 | int snd_seq_port_info_get_timestamp_queue(const snd_seq_port_info_t *info); |
284 | |
285 | void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client); |
286 | void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port); |
287 | void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr); |
288 | void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name); |
289 | void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability); |
290 | void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type); |
291 | void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels); |
292 | void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices); |
293 | void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices); |
294 | void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val); |
295 | void snd_seq_port_info_set_timestamping(snd_seq_port_info_t *info, int enable); |
296 | void snd_seq_port_info_set_timestamp_real(snd_seq_port_info_t *info, int realtime); |
297 | void snd_seq_port_info_set_timestamp_queue(snd_seq_port_info_t *info, int queue); |
298 | |
299 | int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info); |
300 | int snd_seq_delete_port(snd_seq_t *handle, int port); |
301 | int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info); |
302 | int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info); |
303 | int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info); |
304 | int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info); |
305 | |
306 | /** \} */ |
307 | |
308 | |
309 | /** |
310 | * \defgroup SeqSubscribe Sequencer Port Subscription |
311 | * Sequencer Port Subscription |
312 | * \ingroup Sequencer |
313 | * \{ |
314 | */ |
315 | |
316 | /** port subscription container */ |
317 | typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t; |
318 | |
319 | size_t snd_seq_port_subscribe_sizeof(void); |
320 | /** allocate a #snd_seq_port_subscribe_t container on stack */ |
321 | #define snd_seq_port_subscribe_alloca(ptr) \ |
322 | __snd_alloca(ptr, snd_seq_port_subscribe) |
323 | int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr); |
324 | void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr); |
325 | void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src); |
326 | |
327 | const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info); |
328 | const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info); |
329 | int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info); |
330 | int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info); |
331 | int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info); |
332 | int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info); |
333 | |
334 | void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr); |
335 | void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr); |
336 | void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q); |
337 | void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val); |
338 | void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val); |
339 | void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val); |
340 | |
341 | int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); |
342 | int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); |
343 | int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub); |
344 | |
345 | /* |
346 | */ |
347 | |
348 | /** subscription query container */ |
349 | typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t; |
350 | |
351 | /** type of query subscription */ |
352 | typedef enum { |
353 | SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */ |
354 | SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */ |
355 | } snd_seq_query_subs_type_t; |
356 | |
357 | size_t snd_seq_query_subscribe_sizeof(void); |
358 | /** allocate a #snd_seq_query_subscribe_t container on stack */ |
359 | #define snd_seq_query_subscribe_alloca(ptr) \ |
360 | __snd_alloca(ptr, snd_seq_query_subscribe) |
361 | int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr); |
362 | void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr); |
363 | void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src); |
364 | |
365 | int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info); |
366 | int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info); |
367 | const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info); |
368 | snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info); |
369 | int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info); |
370 | int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info); |
371 | const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info); |
372 | int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info); |
373 | int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info); |
374 | int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info); |
375 | int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info); |
376 | |
377 | void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client); |
378 | void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port); |
379 | void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr); |
380 | void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type); |
381 | void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int _index); |
382 | |
383 | int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs); |
384 | |
385 | /** \} */ |
386 | |
387 | |
388 | /** |
389 | * \defgroup SeqQueue Sequencer Queue Interface |
390 | * Sequencer Queue Interface |
391 | * \ingroup Sequencer |
392 | * \{ |
393 | */ |
394 | |
395 | /** queue information container */ |
396 | typedef struct _snd_seq_queue_info snd_seq_queue_info_t; |
397 | /** queue status container */ |
398 | typedef struct _snd_seq_queue_status snd_seq_queue_status_t; |
399 | /** queue tempo container */ |
400 | typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t; |
401 | /** queue timer information container */ |
402 | typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t; |
403 | |
404 | /** special queue ids */ |
405 | #define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */ |
406 | |
407 | size_t snd_seq_queue_info_sizeof(void); |
408 | /** allocate a #snd_seq_queue_info_t container on stack */ |
409 | #define snd_seq_queue_info_alloca(ptr) \ |
410 | __snd_alloca(ptr, snd_seq_queue_info) |
411 | int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr); |
412 | void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr); |
413 | void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src); |
414 | |
415 | int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info); |
416 | const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info); |
417 | int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info); |
418 | int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info); |
419 | unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info); |
420 | |
421 | void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name); |
422 | void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner); |
423 | void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked); |
424 | void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags); |
425 | |
426 | int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info); |
427 | int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name); |
428 | int snd_seq_alloc_queue(snd_seq_t *handle); |
429 | int snd_seq_free_queue(snd_seq_t *handle, int q); |
430 | int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info); |
431 | int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info); |
432 | int snd_seq_query_named_queue(snd_seq_t *seq, const char *name); |
433 | |
434 | int snd_seq_get_queue_usage(snd_seq_t *handle, int q); |
435 | int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used); |
436 | |
437 | /* |
438 | */ |
439 | size_t snd_seq_queue_status_sizeof(void); |
440 | /** allocate a #snd_seq_queue_status_t container on stack */ |
441 | #define snd_seq_queue_status_alloca(ptr) \ |
442 | __snd_alloca(ptr, snd_seq_queue_status) |
443 | int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr); |
444 | void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr); |
445 | void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src); |
446 | |
447 | int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info); |
448 | int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info); |
449 | snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info); |
450 | const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info); |
451 | unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info); |
452 | |
453 | int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status); |
454 | |
455 | /* |
456 | */ |
457 | size_t snd_seq_queue_tempo_sizeof(void); |
458 | /** allocate a #snd_seq_queue_tempo_t container on stack */ |
459 | #define snd_seq_queue_tempo_alloca(ptr) \ |
460 | __snd_alloca(ptr, snd_seq_queue_tempo) |
461 | int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr); |
462 | void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr); |
463 | void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src); |
464 | |
465 | int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info); |
466 | unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info); |
467 | int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info); |
468 | unsigned int snd_seq_queue_tempo_get_skew(const snd_seq_queue_tempo_t *info); |
469 | unsigned int snd_seq_queue_tempo_get_skew_base(const snd_seq_queue_tempo_t *info); |
470 | void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo); |
471 | void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq); |
472 | void snd_seq_queue_tempo_set_skew(snd_seq_queue_tempo_t *info, unsigned int skew); |
473 | void snd_seq_queue_tempo_set_skew_base(snd_seq_queue_tempo_t *info, unsigned int base); |
474 | |
475 | int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo); |
476 | int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo); |
477 | |
478 | /* |
479 | */ |
480 | |
481 | /** sequencer timer sources */ |
482 | typedef enum { |
483 | SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */ |
484 | SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */ |
485 | SND_SEQ_TIMER_MIDI_TICK = 2 /* Midi Timer Tick (TICK event */ |
486 | } snd_seq_queue_timer_type_t; |
487 | |
488 | size_t snd_seq_queue_timer_sizeof(void); |
489 | /** allocate a #snd_seq_queue_timer_t container on stack */ |
490 | #define snd_seq_queue_timer_alloca(ptr) \ |
491 | __snd_alloca(ptr, snd_seq_queue_timer) |
492 | int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr); |
493 | void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr); |
494 | void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src); |
495 | |
496 | int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info); |
497 | snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info); |
498 | const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info); |
499 | unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info); |
500 | |
501 | void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type); |
502 | void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id); |
503 | void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution); |
504 | |
505 | int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer); |
506 | int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer); |
507 | |
508 | /** \} */ |
509 | |
510 | /** |
511 | * \defgroup SeqEvent Sequencer Event API |
512 | * Sequencer Event API |
513 | * \ingroup Sequencer |
514 | * \{ |
515 | */ |
516 | |
517 | int snd_seq_free_event(snd_seq_event_t *ev); |
518 | ssize_t snd_seq_event_length(snd_seq_event_t *ev); |
519 | int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev); |
520 | int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev); |
521 | int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev); |
522 | int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev); |
523 | int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer); |
524 | int snd_seq_drain_output(snd_seq_t *handle); |
525 | int snd_seq_event_output_pending(snd_seq_t *seq); |
526 | int (snd_seq_t *handle, snd_seq_event_t **ev); |
527 | int snd_seq_drop_output(snd_seq_t *handle); |
528 | int snd_seq_drop_output_buffer(snd_seq_t *handle); |
529 | int snd_seq_drop_input(snd_seq_t *handle); |
530 | int snd_seq_drop_input_buffer(snd_seq_t *handle); |
531 | |
532 | /** event removal conditionals */ |
533 | typedef struct _snd_seq_remove_events snd_seq_remove_events_t; |
534 | |
535 | /** Remove conditional flags */ |
536 | #define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */ |
537 | #define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */ |
538 | #define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */ |
539 | #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */ |
540 | #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */ |
541 | #define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */ |
542 | #define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */ |
543 | #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */ |
544 | #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */ |
545 | #define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */ |
546 | |
547 | size_t snd_seq_remove_events_sizeof(void); |
548 | /** allocate a #snd_seq_remove_events_t container on stack */ |
549 | #define snd_seq_remove_events_alloca(ptr) \ |
550 | __snd_alloca(ptr, snd_seq_remove_events) |
551 | int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr); |
552 | void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr); |
553 | void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src); |
554 | |
555 | unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info); |
556 | int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info); |
557 | const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info); |
558 | const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info); |
559 | int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info); |
560 | int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info); |
561 | int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info); |
562 | |
563 | void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags); |
564 | void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue); |
565 | void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time); |
566 | void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr); |
567 | void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel); |
568 | void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type); |
569 | void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag); |
570 | |
571 | int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info); |
572 | |
573 | /** \} */ |
574 | |
575 | /** |
576 | * \defgroup SeqMisc Sequencer Miscellaneous |
577 | * Sequencer Miscellaneous |
578 | * \ingroup Sequencer |
579 | * \{ |
580 | */ |
581 | |
582 | void snd_seq_set_bit(int nr, void *array); |
583 | void snd_seq_unset_bit(int nr, void *array); |
584 | int snd_seq_change_bit(int nr, void *array); |
585 | int snd_seq_get_bit(int nr, void *array); |
586 | |
587 | /** \} */ |
588 | |
589 | |
590 | /** |
591 | * \defgroup SeqEvType Sequencer Event Type Checks |
592 | * Sequencer Event Type Checks |
593 | * \ingroup Sequencer |
594 | * \{ |
595 | */ |
596 | |
597 | /* event type macros */ |
598 | enum { |
599 | SND_SEQ_EVFLG_RESULT, |
600 | SND_SEQ_EVFLG_NOTE, |
601 | SND_SEQ_EVFLG_CONTROL, |
602 | SND_SEQ_EVFLG_QUEUE, |
603 | SND_SEQ_EVFLG_SYSTEM, |
604 | SND_SEQ_EVFLG_MESSAGE, |
605 | SND_SEQ_EVFLG_CONNECTION, |
606 | SND_SEQ_EVFLG_SAMPLE, |
607 | SND_SEQ_EVFLG_USERS, |
608 | SND_SEQ_EVFLG_INSTR, |
609 | SND_SEQ_EVFLG_QUOTE, |
610 | SND_SEQ_EVFLG_NONE, |
611 | SND_SEQ_EVFLG_RAW, |
612 | SND_SEQ_EVFLG_FIXED, |
613 | SND_SEQ_EVFLG_VARIABLE, |
614 | SND_SEQ_EVFLG_VARUSR |
615 | }; |
616 | |
617 | enum { |
618 | SND_SEQ_EVFLG_NOTE_ONEARG, |
619 | SND_SEQ_EVFLG_NOTE_TWOARG |
620 | }; |
621 | |
622 | enum { |
623 | SND_SEQ_EVFLG_QUEUE_NOARG, |
624 | SND_SEQ_EVFLG_QUEUE_TICK, |
625 | SND_SEQ_EVFLG_QUEUE_TIME, |
626 | SND_SEQ_EVFLG_QUEUE_VALUE |
627 | }; |
628 | |
629 | /** |
630 | * Exported event type table |
631 | * |
632 | * This table is referred by snd_seq_ev_is_xxx. |
633 | */ |
634 | extern const unsigned int snd_seq_event_types[]; |
635 | |
636 | #define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */ |
637 | #define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */ |
638 | |
639 | /** check the event type */ |
640 | #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x)) |
641 | |
642 | /** event type check: result events */ |
643 | #define snd_seq_ev_is_result_type(ev) \ |
644 | snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT) |
645 | /** event type check: note events */ |
646 | #define snd_seq_ev_is_note_type(ev) \ |
647 | snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE) |
648 | /** event type check: control events */ |
649 | #define snd_seq_ev_is_control_type(ev) \ |
650 | snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL) |
651 | /** event type check: channel specific events */ |
652 | #define snd_seq_ev_is_channel_type(ev) \ |
653 | (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL))) |
654 | |
655 | /** event type check: queue control events */ |
656 | #define snd_seq_ev_is_queue_type(ev) \ |
657 | snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE) |
658 | /** event type check: system status messages */ |
659 | #define snd_seq_ev_is_message_type(ev) \ |
660 | snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE) |
661 | /** event type check: system status messages */ |
662 | #define snd_seq_ev_is_subscribe_type(ev) \ |
663 | snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION) |
664 | /** event type check: sample messages */ |
665 | #define snd_seq_ev_is_sample_type(ev) \ |
666 | snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE) |
667 | /** event type check: user-defined messages */ |
668 | #define snd_seq_ev_is_user_type(ev) \ |
669 | snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS) |
670 | /** event type check: instrument layer events */ |
671 | #define snd_seq_ev_is_instr_type(ev) \ |
672 | snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR) |
673 | /** event type check: fixed length events */ |
674 | #define snd_seq_ev_is_fixed_type(ev) \ |
675 | snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED) |
676 | /** event type check: variable length events */ |
677 | #define snd_seq_ev_is_variable_type(ev) \ |
678 | snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE) |
679 | /** event type check: user pointer events */ |
680 | #define snd_seq_ev_is_varusr_type(ev) \ |
681 | snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR) |
682 | /** event type check: reserved for kernel */ |
683 | #define snd_seq_ev_is_reserved(ev) \ |
684 | (! snd_seq_event_types[(ev)->type]) |
685 | |
686 | /** |
687 | * macros to check event flags |
688 | */ |
689 | /** prior events */ |
690 | #define snd_seq_ev_is_prior(ev) \ |
691 | (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH) |
692 | |
693 | /** get the data length type */ |
694 | #define snd_seq_ev_length_type(ev) \ |
695 | ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK) |
696 | /** fixed length events */ |
697 | #define snd_seq_ev_is_fixed(ev) \ |
698 | (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED) |
699 | /** variable length events */ |
700 | #define snd_seq_ev_is_variable(ev) \ |
701 | (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE) |
702 | /** variable length on user-space */ |
703 | #define snd_seq_ev_is_varusr(ev) \ |
704 | (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR) |
705 | |
706 | /** time-stamp type */ |
707 | #define snd_seq_ev_timestamp_type(ev) \ |
708 | ((ev)->flags & SND_SEQ_TIME_STAMP_MASK) |
709 | /** event is in tick time */ |
710 | #define snd_seq_ev_is_tick(ev) \ |
711 | (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK) |
712 | /** event is in real-time */ |
713 | #define snd_seq_ev_is_real(ev) \ |
714 | (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL) |
715 | |
716 | /** time-mode type */ |
717 | #define snd_seq_ev_timemode_type(ev) \ |
718 | ((ev)->flags & SND_SEQ_TIME_MODE_MASK) |
719 | /** scheduled in absolute time */ |
720 | #define snd_seq_ev_is_abstime(ev) \ |
721 | (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS) |
722 | /** scheduled in relative time */ |
723 | #define snd_seq_ev_is_reltime(ev) \ |
724 | (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL) |
725 | |
726 | /** direct dispatched events */ |
727 | #define snd_seq_ev_is_direct(ev) \ |
728 | ((ev)->queue == SND_SEQ_QUEUE_DIRECT) |
729 | |
730 | /** \} */ |
731 | |
732 | #ifdef __cplusplus |
733 | } |
734 | #endif |
735 | |
736 | #endif /* __ALSA_SEQ_H */ |
737 | |
738 | |