OSDN Git Service

a9a57e7b960c2010c12f52855603ef7a80e7d56c
[android-x86/external-alsa-lib.git] / include / seq.h
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 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
157 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
158 int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
159 int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info);
160
161 /*
162  */
163
164 /** client pool information container */
165 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
166
167 size_t snd_seq_client_pool_sizeof(void);
168 /** allocate a #snd_seq_client_pool_t container on stack */
169 #define snd_seq_client_pool_alloca(ptr) \
170         __snd_alloca(ptr, snd_seq_client_pool)
171 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
172 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
173 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
174
175 int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info);
176 size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info);
177 size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info);
178 size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info);
179 size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info);
180 size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info);
181 void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size);
182 void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size);
183 void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size);
184
185 int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
186 int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
187
188
189 /** \} */
190
191
192 /**
193  *  \defgroup SeqPort Sequencer Port Interface
194  *  Sequencer Port Interface
195  *  \ingroup Sequencer
196  *  \{
197  */
198
199 /** port information container */
200 typedef struct _snd_seq_port_info snd_seq_port_info_t;
201
202 /** known port numbers */
203 #define SND_SEQ_PORT_SYSTEM_TIMER       0       /**< system timer port */
204 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE    1       /**< system announce port */
205
206 /** port capabilities (32 bits) */
207 #define SND_SEQ_PORT_CAP_READ           (1<<0)  /**< readable from this port */
208 #define SND_SEQ_PORT_CAP_WRITE          (1<<1)  /**< writable to this port */
209
210 #define SND_SEQ_PORT_CAP_SYNC_READ      (1<<2)  /**< allow read subscriptions */
211 #define SND_SEQ_PORT_CAP_SYNC_WRITE     (1<<3)  /**< allow write subscriptions */
212
213 #define SND_SEQ_PORT_CAP_DUPLEX         (1<<4)  /**< allow read/write duplex */
214
215 #define SND_SEQ_PORT_CAP_SUBS_READ      (1<<5)  /**< allow read subscription */
216 #define SND_SEQ_PORT_CAP_SUBS_WRITE     (1<<6)  /**< allow write subscription */
217 #define SND_SEQ_PORT_CAP_NO_EXPORT      (1<<7)  /**< routing not allowed */
218
219 /* port type */
220 /** Messages sent from/to this port have device-specific semantics. */
221 #define SND_SEQ_PORT_TYPE_SPECIFIC      (1<<0)
222 /** This port understands MIDI messages. */
223 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC  (1<<1)
224 /** This port is compatible with the General MIDI specification. */
225 #define SND_SEQ_PORT_TYPE_MIDI_GM       (1<<2)
226 /** This port is compatible with the Roland GS standard. */
227 #define SND_SEQ_PORT_TYPE_MIDI_GS       (1<<3)
228 /** This port is compatible with the Yamaha XG specification. */
229 #define SND_SEQ_PORT_TYPE_MIDI_XG       (1<<4)
230 /** This port is compatible with the Roland MT-32. */
231 #define SND_SEQ_PORT_TYPE_MIDI_MT32     (1<<5)
232 /** This port is compatible with the General MIDI 2 specification. */
233 #define SND_SEQ_PORT_TYPE_MIDI_GM2      (1<<6)
234 /** This port understands SND_SEQ_EVENT_SAMPLE_xxx messages
235     (these are not MIDI messages). */
236 #define SND_SEQ_PORT_TYPE_SYNTH         (1<<10)
237 /** Instruments can be downloaded to this port
238     (with SND_SEQ_EVENT_INSTR_xxx messages sent directly). */
239 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11)
240 /** Instruments can be downloaded to this port
241     (with SND_SEQ_EVENT_INSTR_xxx messages sent directly or through a queue). */
242 #define SND_SEQ_PORT_TYPE_SAMPLE        (1<<12)
243 /** This port is implemented in hardware. */
244 #define SND_SEQ_PORT_TYPE_HARDWARE      (1<<16)
245 /** This port is implemented in software. */
246 #define SND_SEQ_PORT_TYPE_SOFTWARE      (1<<17)
247 /** Messages sent to this port will generate sounds. */
248 #define SND_SEQ_PORT_TYPE_SYNTHESIZER   (1<<18)
249 /** This port may connect to other devices
250     (whose characteristics are not known). */
251 #define SND_SEQ_PORT_TYPE_PORT          (1<<19)
252 /** This port belongs to an application, such as a sequencer or editor. */
253 #define SND_SEQ_PORT_TYPE_APPLICATION   (1<<20)
254
255
256 size_t snd_seq_port_info_sizeof(void);
257 /** allocate a #snd_seq_port_info_t container on stack */
258 #define snd_seq_port_info_alloca(ptr) \
259         __snd_alloca(ptr, snd_seq_port_info)
260 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
261 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
262 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
263
264 int snd_seq_port_info_get_client(const snd_seq_port_info_t *info);
265 int snd_seq_port_info_get_port(const snd_seq_port_info_t *info);
266 const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info);
267 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
268 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
269 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
270 int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info);
271 int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info);
272 int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info);
273 int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info);
274 int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info);
275 int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info);
276 int snd_seq_port_info_get_timestamping(const snd_seq_port_info_t *info);
277 int snd_seq_port_info_get_timestamp_real(const snd_seq_port_info_t *info);
278 int snd_seq_port_info_get_timestamp_queue(const snd_seq_port_info_t *info);
279
280 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
281 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
282 void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr);
283 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
284 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
285 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
286 void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels);
287 void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices);
288 void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices);
289 void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val);
290 void snd_seq_port_info_set_timestamping(snd_seq_port_info_t *info, int enable);
291 void snd_seq_port_info_set_timestamp_real(snd_seq_port_info_t *info, int realtime);
292 void snd_seq_port_info_set_timestamp_queue(snd_seq_port_info_t *info, int queue);
293
294 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
295 int snd_seq_delete_port(snd_seq_t *handle, int port);
296 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
297 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
298 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
299 int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info);
300
301 /** \} */
302
303
304 /**
305  *  \defgroup SeqSubscribe Sequencer Port Subscription
306  *  Sequencer Port Subscription
307  *  \ingroup Sequencer
308  *  \{
309  */
310
311 /** port subscription container */
312 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
313
314 size_t snd_seq_port_subscribe_sizeof(void);
315 /** allocate a #snd_seq_port_subscribe_t container on stack */
316 #define snd_seq_port_subscribe_alloca(ptr) \
317         __snd_alloca(ptr, snd_seq_port_subscribe)
318 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
319 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
320 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
321
322 const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info);
323 const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info);
324 int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info);
325 int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info);
326 int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info);
327 int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info);
328
329 void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
330 void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
331 void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q);
332 void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val);
333 void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val);
334 void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val);
335
336 int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
337 int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
338 int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
339
340 /*
341  */
342
343 /** subscription query container */
344 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
345
346 /** type of query subscription */
347 typedef enum {
348         SND_SEQ_QUERY_SUBS_READ,        /**< query read subscriptions */
349         SND_SEQ_QUERY_SUBS_WRITE        /**< query write subscriptions */
350 } snd_seq_query_subs_type_t;
351
352 size_t snd_seq_query_subscribe_sizeof(void);
353 /** allocate a #snd_seq_query_subscribe_t container on stack */
354 #define snd_seq_query_subscribe_alloca(ptr) \
355         __snd_alloca(ptr, snd_seq_query_subscribe)
356 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
357 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
358 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
359
360 int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info);
361 int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info);
362 const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info);
363 snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info);
364 int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info);
365 int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info);
366 const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info);
367 int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info);
368 int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info);
369 int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info);
370 int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info);
371
372 void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client);
373 void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port);
374 void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr);
375 void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type);
376 void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int _index);
377
378 int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs);
379
380 /** \} */
381
382
383 /**
384  *  \defgroup SeqQueue Sequencer Queue Interface
385  *  Sequencer Queue Interface
386  *  \ingroup Sequencer
387  *  \{
388  */
389
390 /** queue information container */
391 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
392 /** queue status container */
393 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
394 /** queue tempo container */
395 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
396 /** queue timer information container */
397 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
398
399 /** special queue ids */
400 #define SND_SEQ_QUEUE_DIRECT            253     /**< direct dispatch */
401
402 size_t snd_seq_queue_info_sizeof(void);
403 /** allocate a #snd_seq_queue_info_t container on stack */
404 #define snd_seq_queue_info_alloca(ptr) \
405         __snd_alloca(ptr, snd_seq_queue_info)
406 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
407 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
408 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
409
410 int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info);
411 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
412 int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info);
413 int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info);
414 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
415
416 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
417 void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner);
418 void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked);
419 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
420
421 int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
422 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
423 int snd_seq_alloc_queue(snd_seq_t *handle);
424 int snd_seq_free_queue(snd_seq_t *handle, int q);
425 int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
426 int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
427 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
428
429 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
430 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
431
432 /*
433  */
434 size_t snd_seq_queue_status_sizeof(void);
435 /** allocate a #snd_seq_queue_status_t container on stack */
436 #define snd_seq_queue_status_alloca(ptr) \
437         __snd_alloca(ptr, snd_seq_queue_status)
438 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
439 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
440 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
441
442 int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info);
443 int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info);
444 snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
445 const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info);
446 unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info);
447
448 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
449
450 /*
451  */
452 size_t snd_seq_queue_tempo_sizeof(void);
453 /** allocate a #snd_seq_queue_tempo_t container on stack */
454 #define snd_seq_queue_tempo_alloca(ptr) \
455         __snd_alloca(ptr, snd_seq_queue_tempo)
456 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
457 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
458 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
459
460 int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info);
461 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
462 int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info);
463 unsigned int snd_seq_queue_tempo_get_skew(const snd_seq_queue_tempo_t *info);
464 unsigned int snd_seq_queue_tempo_get_skew_base(const snd_seq_queue_tempo_t *info);
465 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
466 void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq);
467 void snd_seq_queue_tempo_set_skew(snd_seq_queue_tempo_t *info, unsigned int skew);
468 void snd_seq_queue_tempo_set_skew_base(snd_seq_queue_tempo_t *info, unsigned int base);
469
470 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
471 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
472
473 /*
474  */
475
476 /** sequencer timer sources */
477 typedef enum {
478         SND_SEQ_TIMER_ALSA = 0,         /* ALSA timer */
479         SND_SEQ_TIMER_MIDI_CLOCK = 1,   /* Midi Clock (CLOCK event) */
480         SND_SEQ_TIMER_MIDI_TICK = 2     /* Midi Timer Tick (TICK event */
481 } snd_seq_queue_timer_type_t;
482
483 size_t snd_seq_queue_timer_sizeof(void);
484 /** allocate a #snd_seq_queue_timer_t container on stack */
485 #define snd_seq_queue_timer_alloca(ptr) \
486         __snd_alloca(ptr, snd_seq_queue_timer)
487 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
488 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
489 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
490
491 int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info);
492 snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info);
493 const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info);
494 unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info);
495
496 void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type);
497 void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id);
498 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
499
500 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
501 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
502
503 /** \} */
504
505 /**
506  *  \defgroup SeqEvent Sequencer Event API
507  *  Sequencer Event API
508  *  \ingroup Sequencer
509  *  \{
510  */
511
512 int snd_seq_free_event(snd_seq_event_t *ev);
513 ssize_t snd_seq_event_length(snd_seq_event_t *ev);
514 int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev);
515 int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev);
516 int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
517 int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
518 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
519 int snd_seq_drain_output(snd_seq_t *handle);
520 int snd_seq_event_output_pending(snd_seq_t *seq);
521 int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
522 int snd_seq_drop_output(snd_seq_t *handle);
523 int snd_seq_drop_output_buffer(snd_seq_t *handle);
524 int snd_seq_drop_input(snd_seq_t *handle);
525 int snd_seq_drop_input_buffer(snd_seq_t *handle);
526
527 /** event removal conditionals */
528 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
529
530 /** Remove conditional flags */
531 #define SND_SEQ_REMOVE_INPUT            (1<<0)  /**< Flush input queues */
532 #define SND_SEQ_REMOVE_OUTPUT           (1<<1)  /**< Flush output queues */
533 #define SND_SEQ_REMOVE_DEST             (1<<2)  /**< Restrict by destination q:client:port */
534 #define SND_SEQ_REMOVE_DEST_CHANNEL     (1<<3)  /**< Restrict by channel */
535 #define SND_SEQ_REMOVE_TIME_BEFORE      (1<<4)  /**< Restrict to before time */
536 #define SND_SEQ_REMOVE_TIME_AFTER       (1<<5)  /**< Restrict to time or after */
537 #define SND_SEQ_REMOVE_TIME_TICK        (1<<6)  /**< Time is in ticks */
538 #define SND_SEQ_REMOVE_EVENT_TYPE       (1<<7)  /**< Restrict to event type */
539 #define SND_SEQ_REMOVE_IGNORE_OFF       (1<<8)  /**< Do not flush off events */
540 #define SND_SEQ_REMOVE_TAG_MATCH        (1<<9)  /**< Restrict to events with given tag */
541
542 size_t snd_seq_remove_events_sizeof(void);
543 /** allocate a #snd_seq_remove_events_t container on stack */
544 #define snd_seq_remove_events_alloca(ptr) \
545         __snd_alloca(ptr, snd_seq_remove_events)
546 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
547 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
548 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
549
550 unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info);
551 int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info);
552 const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info);
553 const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info);
554 int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info);
555 int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info);
556 int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info);
557
558 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
559 void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue);
560 void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time);
561 void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr);
562 void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel);
563 void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type);
564 void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag);
565
566 int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
567
568 /** \} */
569
570 /**
571  *  \defgroup SeqMisc Sequencer Miscellaneous
572  *  Sequencer Miscellaneous
573  *  \ingroup Sequencer
574  *  \{
575  */
576
577 void snd_seq_set_bit(int nr, void *array);
578 void snd_seq_unset_bit(int nr, void *array);
579 int snd_seq_change_bit(int nr, void *array);
580 int snd_seq_get_bit(int nr, void *array);
581
582 /** \} */
583
584
585 /**
586  *  \defgroup SeqEvType Sequencer Event Type Checks
587  *  Sequencer Event Type Checks
588  *  \ingroup Sequencer
589  *  \{
590  */
591
592 /* event type macros */
593 enum {
594         SND_SEQ_EVFLG_RESULT,
595         SND_SEQ_EVFLG_NOTE,
596         SND_SEQ_EVFLG_CONTROL,
597         SND_SEQ_EVFLG_QUEUE,
598         SND_SEQ_EVFLG_SYSTEM,
599         SND_SEQ_EVFLG_MESSAGE,
600         SND_SEQ_EVFLG_CONNECTION,
601         SND_SEQ_EVFLG_SAMPLE,
602         SND_SEQ_EVFLG_USERS,
603         SND_SEQ_EVFLG_INSTR,
604         SND_SEQ_EVFLG_QUOTE,
605         SND_SEQ_EVFLG_NONE,
606         SND_SEQ_EVFLG_RAW,
607         SND_SEQ_EVFLG_FIXED,
608         SND_SEQ_EVFLG_VARIABLE,
609         SND_SEQ_EVFLG_VARUSR
610 };
611
612 enum {
613         SND_SEQ_EVFLG_NOTE_ONEARG,
614         SND_SEQ_EVFLG_NOTE_TWOARG
615 };
616
617 enum {
618         SND_SEQ_EVFLG_QUEUE_NOARG,
619         SND_SEQ_EVFLG_QUEUE_TICK,
620         SND_SEQ_EVFLG_QUEUE_TIME,
621         SND_SEQ_EVFLG_QUEUE_VALUE
622 };
623
624 /**
625  * Exported event type table
626  *
627  * This table is referred by snd_seq_ev_is_xxx.
628  */
629 extern const unsigned int snd_seq_event_types[];
630
631 #define _SND_SEQ_TYPE(x)        (1<<(x))        /**< master type - 24bit */
632 #define _SND_SEQ_TYPE_OPT(x)    ((x)<<24)       /**< optional type - 8bit */
633
634 /** check the event type */
635 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
636
637 /** event type check: result events */
638 #define snd_seq_ev_is_result_type(ev) \
639         snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
640 /** event type check: note events */
641 #define snd_seq_ev_is_note_type(ev) \
642         snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
643 /** event type check: control events */
644 #define snd_seq_ev_is_control_type(ev) \
645         snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
646 /** event type check: channel specific events */
647 #define snd_seq_ev_is_channel_type(ev) \
648         (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
649
650 /** event type check: queue control events */
651 #define snd_seq_ev_is_queue_type(ev) \
652         snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
653 /** event type check: system status messages */
654 #define snd_seq_ev_is_message_type(ev) \
655         snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
656 /** event type check: system status messages */
657 #define snd_seq_ev_is_subscribe_type(ev) \
658         snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
659 /** event type check: sample messages */
660 #define snd_seq_ev_is_sample_type(ev) \
661         snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
662 /** event type check: user-defined messages */
663 #define snd_seq_ev_is_user_type(ev) \
664         snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
665 /** event type check: instrument layer events */
666 #define snd_seq_ev_is_instr_type(ev) \
667         snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
668 /** event type check: fixed length events */
669 #define snd_seq_ev_is_fixed_type(ev) \
670         snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
671 /** event type check: variable length events */
672 #define snd_seq_ev_is_variable_type(ev) \
673         snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
674 /** event type check: user pointer events */
675 #define snd_seq_ev_is_varusr_type(ev) \
676         snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
677 /** event type check: reserved for kernel */
678 #define snd_seq_ev_is_reserved(ev) \
679         (! snd_seq_event_types[(ev)->type])
680
681 /**
682  * macros to check event flags
683  */
684 /** prior events */
685 #define snd_seq_ev_is_prior(ev) \
686         (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
687
688 /** get the data length type */
689 #define snd_seq_ev_length_type(ev) \
690         ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
691 /** fixed length events */
692 #define snd_seq_ev_is_fixed(ev) \
693         (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
694 /** variable length events */
695 #define snd_seq_ev_is_variable(ev) \
696         (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
697 /** variable length on user-space */
698 #define snd_seq_ev_is_varusr(ev) \
699         (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
700
701 /** time-stamp type */
702 #define snd_seq_ev_timestamp_type(ev) \
703         ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
704 /** event is in tick time */
705 #define snd_seq_ev_is_tick(ev) \
706         (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
707 /** event is in real-time */
708 #define snd_seq_ev_is_real(ev) \
709         (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
710
711 /** time-mode type */
712 #define snd_seq_ev_timemode_type(ev) \
713         ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
714 /** scheduled in absolute time */
715 #define snd_seq_ev_is_abstime(ev) \
716         (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
717 /** scheduled in relative time */
718 #define snd_seq_ev_is_reltime(ev) \
719         (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
720
721 /** direct dispatched events */
722 #define snd_seq_ev_is_direct(ev) \
723         ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
724
725 /** \} */
726
727 #ifdef __cplusplus
728 }
729 #endif
730
731 #endif /* __ALSA_SEQ_H */
732