3 * \brief Application interface library for the ALSA driver
4 * \author Jaroslav Kysela <perex@suse.cz>
5 * \author Abramo Bagnara <abramo@alsa-project.org>
6 * \author Takashi Iwai <tiwai@suse.de>
9 * Application interface library for the ALSA driver
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 * \defgroup SeqGlobal Sequencer System
33 * Global System Interface
42 /** dlsym version for interface entry callback */
43 #define SND_SEQ_DLSYM_VERSION _dlsym_seq_001
45 /** Sequencer handle */
46 typedef struct _snd_seq snd_seq_t;
49 #define SND_ALLOCA(type,ptr) \
52 *ptr = (type##_t *)alloca(type##_sizeof());\
53 memset(*ptr, 0, type##_sizeof());\
57 * sequencer opening stream types
59 #define SND_SEQ_OPEN_OUTPUT 1 /**< open for output (write) */
60 #define SND_SEQ_OPEN_INPUT 2 /**< open for input (read) */
61 #define SND_SEQ_OPEN_DUPLEX (SND_SEQ_OPEN_OUTPUT|SND_SEQ_OPEN_INPUT) /**< open for both input and output (read/write) */
64 * sequencer opening mode
66 #define SND_SEQ_NONBLOCK 1 /**< non-blocking mode */
68 /** sequencer handle type */
69 typedef enum _snd_seq_type {
70 SND_SEQ_TYPE_HW, /**< hardware */
71 SND_SEQ_TYPE_SHM, /**< shared memory (NYI) */
72 SND_SEQ_TYPE_INET, /**< network (NYI) */
75 /** special client (port) ids */
76 #define SND_SEQ_ADDRESS_UNKNOWN 253 /**< unknown source */
77 #define SND_SEQ_ADDRESS_SUBSCRIBERS 254 /**< send event to all subscribed ports */
78 #define SND_SEQ_ADDRESS_BROADCAST 255 /**< send event to all queues/clients/ports/channels */
80 /** known client numbers */
81 #define SND_SEQ_CLIENT_SYSTEM 0 /**< system client */
82 #define SND_SEQ_CLIENT_DUMMY 62 /**< dummy ports */
83 #define SND_SEQ_CLIENT_OSS 63 /**< oss sequencer emulator */
87 int snd_seq_open(snd_seq_t **handle, const char *name, int streams, int mode);
88 const char *snd_seq_name(snd_seq_t *seq);
89 snd_seq_type_t snd_seq_type(snd_seq_t *seq);
90 int snd_seq_close(snd_seq_t *handle);
91 int snd_seq_poll_descriptors_count(snd_seq_t *handle, short events);
92 int snd_seq_poll_descriptors(snd_seq_t *handle, struct pollfd *pfds, unsigned int space, short events);
93 int snd_seq_nonblock(snd_seq_t *handle, int nonblock);
94 int snd_seq_client_id(snd_seq_t *handle);
96 size_t snd_seq_get_output_buffer_size(snd_seq_t *handle);
97 size_t snd_seq_get_input_buffer_size(snd_seq_t *handle);
98 int snd_seq_set_output_buffer_size(snd_seq_t *handle, size_t size);
99 int snd_seq_set_input_buffer_size(snd_seq_t *handle, size_t size);
101 /** system information container */
102 typedef struct _snd_seq_system_info snd_seq_system_info_t;
104 size_t snd_seq_system_info_sizeof(void);
105 /** allocate a #snd_seq_system_info_t container on stack */
106 #define snd_seq_system_info_alloca(ptr) \
107 SND_ALLOCA(snd_seq_system_info, ptr)
108 int snd_seq_system_info_malloc(snd_seq_system_info_t **ptr);
109 void snd_seq_system_info_free(snd_seq_system_info_t *ptr);
110 void snd_seq_system_info_copy(snd_seq_system_info_t *dst, const snd_seq_system_info_t *src);
112 int snd_seq_system_info_get_queues(const snd_seq_system_info_t *info);
113 int snd_seq_system_info_get_clients(const snd_seq_system_info_t *info);
114 int snd_seq_system_info_get_ports(const snd_seq_system_info_t *info);
115 int snd_seq_system_info_get_channels(const snd_seq_system_info_t *info);
116 int snd_seq_system_info_get_cur_clients(const snd_seq_system_info_t *info);
117 int snd_seq_system_info_get_cur_queues(const snd_seq_system_info_t *info);
119 int snd_seq_system_info(snd_seq_t *handle, snd_seq_system_info_t *info);
125 * \defgroup SeqClient Sequencer Client Interface
126 * Sequencer Client Interface
131 /** client information container */
132 typedef struct _snd_seq_client_info snd_seq_client_info_t;
135 typedef enum snd_seq_client_type {
136 SND_SEQ_USER_CLIENT = 1, /**< user client */
137 SND_SEQ_KERNEL_CLIENT = 2 /**< kernel client */
138 } snd_seq_client_type_t;
140 size_t snd_seq_client_info_sizeof(void);
141 /** allocate a #snd_seq_client_info_t container on stack */
142 #define snd_seq_client_info_alloca(ptr) \
143 SND_ALLOCA(snd_seq_client_info, ptr)
144 int snd_seq_client_info_malloc(snd_seq_client_info_t **ptr);
145 void snd_seq_client_info_free(snd_seq_client_info_t *ptr);
146 void snd_seq_client_info_copy(snd_seq_client_info_t *dst, const snd_seq_client_info_t *src);
148 int snd_seq_client_info_get_client(const snd_seq_client_info_t *info);
149 snd_seq_client_type_t snd_seq_client_info_get_type(const snd_seq_client_info_t *info);
150 const char *snd_seq_client_info_get_name(snd_seq_client_info_t *info);
151 int snd_seq_client_info_get_broadcast_filter(const snd_seq_client_info_t *info);
152 int snd_seq_client_info_get_error_bounce(const snd_seq_client_info_t *info);
153 const unsigned char *snd_seq_client_info_get_event_filter(const snd_seq_client_info_t *info);
154 int snd_seq_client_info_get_num_ports(const snd_seq_client_info_t *info);
155 int snd_seq_client_info_get_event_lost(const snd_seq_client_info_t *info);
157 void snd_seq_client_info_set_client(snd_seq_client_info_t *info, int client);
158 void snd_seq_client_info_set_name(snd_seq_client_info_t *info, const char *name);
159 void snd_seq_client_info_set_broadcast_filter(snd_seq_client_info_t *info, int val);
160 void snd_seq_client_info_set_error_bounce(snd_seq_client_info_t *info, int val);
161 void snd_seq_client_info_set_event_filter(snd_seq_client_info_t *info, unsigned char *filter);
163 int snd_seq_get_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
164 int snd_seq_get_any_client_info(snd_seq_t *handle, int client, snd_seq_client_info_t *info);
165 int snd_seq_set_client_info(snd_seq_t *handle, snd_seq_client_info_t *info);
166 int snd_seq_query_next_client(snd_seq_t *handle, snd_seq_client_info_t *info);
171 /** client pool information container */
172 typedef struct _snd_seq_client_pool snd_seq_client_pool_t;
174 size_t snd_seq_client_pool_sizeof(void);
175 /** allocate a #snd_seq_client_pool_t container on stack */
176 #define snd_seq_client_pool_alloca(ptr) \
177 SND_ALLOCA(snd_seq_client_pool, ptr)
178 int snd_seq_client_pool_malloc(snd_seq_client_pool_t **ptr);
179 void snd_seq_client_pool_free(snd_seq_client_pool_t *ptr);
180 void snd_seq_client_pool_copy(snd_seq_client_pool_t *dst, const snd_seq_client_pool_t *src);
182 int snd_seq_client_pool_get_client(const snd_seq_client_pool_t *info);
183 size_t snd_seq_client_pool_get_output_pool(const snd_seq_client_pool_t *info);
184 size_t snd_seq_client_pool_get_input_pool(const snd_seq_client_pool_t *info);
185 size_t snd_seq_client_pool_get_output_room(const snd_seq_client_pool_t *info);
186 size_t snd_seq_client_pool_get_output_free(const snd_seq_client_pool_t *info);
187 size_t snd_seq_client_pool_get_input_free(const snd_seq_client_pool_t *info);
188 void snd_seq_client_pool_set_output_pool(snd_seq_client_pool_t *info, size_t size);
189 void snd_seq_client_pool_set_input_pool(snd_seq_client_pool_t *info, size_t size);
190 void snd_seq_client_pool_set_output_room(snd_seq_client_pool_t *info, size_t size);
192 int snd_seq_get_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
193 int snd_seq_set_client_pool(snd_seq_t *handle, snd_seq_client_pool_t *info);
200 * \defgroup SeqPort Sequencer Port Interface
201 * Sequencer Port Interface
206 /** port information container */
207 typedef struct _snd_seq_port_info snd_seq_port_info_t;
209 /** known port numbers */
210 #define SND_SEQ_PORT_SYSTEM_TIMER 0 /**< system timer port */
211 #define SND_SEQ_PORT_SYSTEM_ANNOUNCE 1 /**< sysem announce port */
213 /** port capabilities (32 bits) */
214 #define SND_SEQ_PORT_CAP_READ (1<<0) /**< readable from this port */
215 #define SND_SEQ_PORT_CAP_WRITE (1<<1) /**< writable to this port */
217 #define SND_SEQ_PORT_CAP_SYNC_READ (1<<2) /**< allow read subscriptions */
218 #define SND_SEQ_PORT_CAP_SYNC_WRITE (1<<3) /**< allow write subscriptions */
220 #define SND_SEQ_PORT_CAP_DUPLEX (1<<4) /**< allow read/write duplex */
222 #define SND_SEQ_PORT_CAP_SUBS_READ (1<<5) /**< allow read subscription */
223 #define SND_SEQ_PORT_CAP_SUBS_WRITE (1<<6) /**< allow write subscription */
224 #define SND_SEQ_PORT_CAP_NO_EXPORT (1<<7) /**< routing not allowed */
227 #define SND_SEQ_PORT_TYPE_SPECIFIC (1<<0) /**< hardware specific */
228 #define SND_SEQ_PORT_TYPE_MIDI_GENERIC (1<<1) /**< generic MIDI device */
229 #define SND_SEQ_PORT_TYPE_MIDI_GM (1<<2) /**< General MIDI compatible device */
230 #define SND_SEQ_PORT_TYPE_MIDI_GS (1<<3) /**< GS compatible device */
231 #define SND_SEQ_PORT_TYPE_MIDI_XG (1<<4) /**< XG compatible device */
232 #define SND_SEQ_PORT_TYPE_MIDI_MT32 (1<<5) /**< MT-32 compatible device */
233 #define SND_SEQ_PORT_TYPE_SYNTH (1<<10) /**< Synth device */
234 #define SND_SEQ_PORT_TYPE_DIRECT_SAMPLE (1<<11) /**< Sampling device (support sample download) */
235 #define SND_SEQ_PORT_TYPE_SAMPLE (1<<12) /**< Sampling device (sample can be downloaded at any time) */
236 #define SND_SEQ_PORT_TYPE_APPLICATION (1<<20) /**< application (sequencer/editor) */
239 size_t snd_seq_port_info_sizeof(void);
240 /** allocate a #snd_seq_port_info_t container on stack */
241 #define snd_seq_port_info_alloca(ptr) \
242 SND_ALLOCA(snd_seq_port_info, ptr)
243 int snd_seq_port_info_malloc(snd_seq_port_info_t **ptr);
244 void snd_seq_port_info_free(snd_seq_port_info_t *ptr);
245 void snd_seq_port_info_copy(snd_seq_port_info_t *dst, const snd_seq_port_info_t *src);
247 int snd_seq_port_info_get_client(const snd_seq_port_info_t *info);
248 int snd_seq_port_info_get_port(const snd_seq_port_info_t *info);
249 const snd_seq_addr_t *snd_seq_port_info_get_addr(const snd_seq_port_info_t *info);
250 const char *snd_seq_port_info_get_name(const snd_seq_port_info_t *info);
251 unsigned int snd_seq_port_info_get_capability(const snd_seq_port_info_t *info);
252 unsigned int snd_seq_port_info_get_type(const snd_seq_port_info_t *info);
253 int snd_seq_port_info_get_midi_channels(const snd_seq_port_info_t *info);
254 int snd_seq_port_info_get_midi_voices(const snd_seq_port_info_t *info);
255 int snd_seq_port_info_get_synth_voices(const snd_seq_port_info_t *info);
256 int snd_seq_port_info_get_read_use(const snd_seq_port_info_t *info);
257 int snd_seq_port_info_get_write_use(const snd_seq_port_info_t *info);
258 int snd_seq_port_info_get_port_specified(const snd_seq_port_info_t *info);
260 void snd_seq_port_info_set_client(snd_seq_port_info_t *info, int client);
261 void snd_seq_port_info_set_port(snd_seq_port_info_t *info, int port);
262 void snd_seq_port_info_set_addr(snd_seq_port_info_t *info, const snd_seq_addr_t *addr);
263 void snd_seq_port_info_set_name(snd_seq_port_info_t *info, const char *name);
264 void snd_seq_port_info_set_capability(snd_seq_port_info_t *info, unsigned int capability);
265 void snd_seq_port_info_set_type(snd_seq_port_info_t *info, unsigned int type);
266 void snd_seq_port_info_set_midi_channels(snd_seq_port_info_t *info, int channels);
267 void snd_seq_port_info_set_midi_voices(snd_seq_port_info_t *info, int voices);
268 void snd_seq_port_info_set_synth_voices(snd_seq_port_info_t *info, int voices);
269 void snd_seq_port_info_set_port_specified(snd_seq_port_info_t *info, int val);
271 int snd_seq_create_port(snd_seq_t *handle, snd_seq_port_info_t *info);
272 int snd_seq_delete_port(snd_seq_t *handle, int port);
273 int snd_seq_get_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
274 int snd_seq_get_any_port_info(snd_seq_t *handle, int client, int port, snd_seq_port_info_t *info);
275 int snd_seq_set_port_info(snd_seq_t *handle, int port, snd_seq_port_info_t *info);
276 int snd_seq_query_next_port(snd_seq_t *handle, snd_seq_port_info_t *info);
282 * \defgroup SeqSubscribe Sequencer Port Subscription
283 * Sequencer Port Subscription
288 /** port subscription container */
289 typedef struct _snd_seq_port_subscribe snd_seq_port_subscribe_t;
291 size_t snd_seq_port_subscribe_sizeof(void);
292 /** allocate a #snd_seq_port_subscribe_t container on stack */
293 #define snd_seq_port_subscribe_alloca(ptr) \
294 SND_ALLOCA(snd_seq_port_subscribe, ptr)
295 int snd_seq_port_subscribe_malloc(snd_seq_port_subscribe_t **ptr);
296 void snd_seq_port_subscribe_free(snd_seq_port_subscribe_t *ptr);
297 void snd_seq_port_subscribe_copy(snd_seq_port_subscribe_t *dst, const snd_seq_port_subscribe_t *src);
299 const snd_seq_addr_t *snd_seq_port_subscribe_get_sender(const snd_seq_port_subscribe_t *info);
300 const snd_seq_addr_t *snd_seq_port_subscribe_get_dest(const snd_seq_port_subscribe_t *info);
301 int snd_seq_port_subscribe_get_queue(const snd_seq_port_subscribe_t *info);
302 int snd_seq_port_subscribe_get_exclusive(const snd_seq_port_subscribe_t *info);
303 int snd_seq_port_subscribe_get_time_update(const snd_seq_port_subscribe_t *info);
304 int snd_seq_port_subscribe_get_time_real(const snd_seq_port_subscribe_t *info);
306 void snd_seq_port_subscribe_set_sender(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
307 void snd_seq_port_subscribe_set_dest(snd_seq_port_subscribe_t *info, const snd_seq_addr_t *addr);
308 void snd_seq_port_subscribe_set_queue(snd_seq_port_subscribe_t *info, int q);
309 void snd_seq_port_subscribe_set_exclusive(snd_seq_port_subscribe_t *info, int val);
310 void snd_seq_port_subscribe_set_time_update(snd_seq_port_subscribe_t *info, int val);
311 void snd_seq_port_subscribe_set_time_real(snd_seq_port_subscribe_t *info, int val);
313 int snd_seq_get_port_subscription(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
314 int snd_seq_subscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
315 int snd_seq_unsubscribe_port(snd_seq_t *handle, snd_seq_port_subscribe_t *sub);
320 /** subscription query container */
321 typedef struct _snd_seq_query_subscribe snd_seq_query_subscribe_t;
323 /** type of query subscription */
325 SND_SEQ_QUERY_SUBS_READ, /**< query read subscriptions */
326 SND_SEQ_QUERY_SUBS_WRITE /**< query write subscriptions */
327 } snd_seq_query_subs_type_t;
329 size_t snd_seq_query_subscribe_sizeof(void);
330 /** allocate a #snd_seq_query_subscribe_t container on stack */
331 #define snd_seq_query_subscribe_alloca(ptr) \
332 SND_ALLOCA(snd_seq_query_subscribe, ptr)
333 int snd_seq_query_subscribe_malloc(snd_seq_query_subscribe_t **ptr);
334 void snd_seq_query_subscribe_free(snd_seq_query_subscribe_t *ptr);
335 void snd_seq_query_subscribe_copy(snd_seq_query_subscribe_t *dst, const snd_seq_query_subscribe_t *src);
337 int snd_seq_query_subscribe_get_client(const snd_seq_query_subscribe_t *info);
338 int snd_seq_query_subscribe_get_port(const snd_seq_query_subscribe_t *info);
339 const snd_seq_addr_t *snd_seq_query_subscribe_get_root(const snd_seq_query_subscribe_t *info);
340 snd_seq_query_subs_type_t snd_seq_query_subscribe_get_type(const snd_seq_query_subscribe_t *info);
341 int snd_seq_query_subscribe_get_index(const snd_seq_query_subscribe_t *info);
342 int snd_seq_query_subscribe_get_num_subs(const snd_seq_query_subscribe_t *info);
343 const snd_seq_addr_t *snd_seq_query_subscribe_get_addr(const snd_seq_query_subscribe_t *info);
344 int snd_seq_query_subscribe_get_queue(const snd_seq_query_subscribe_t *info);
345 int snd_seq_query_subscribe_get_exclusive(const snd_seq_query_subscribe_t *info);
346 int snd_seq_query_subscribe_get_time_update(const snd_seq_query_subscribe_t *info);
347 int snd_seq_query_subscribe_get_time_real(const snd_seq_query_subscribe_t *info);
349 void snd_seq_query_subscribe_set_client(snd_seq_query_subscribe_t *info, int client);
350 void snd_seq_query_subscribe_set_port(snd_seq_query_subscribe_t *info, int port);
351 void snd_seq_query_subscribe_set_root(snd_seq_query_subscribe_t *info, const snd_seq_addr_t *addr);
352 void snd_seq_query_subscribe_set_type(snd_seq_query_subscribe_t *info, snd_seq_query_subs_type_t type);
353 void snd_seq_query_subscribe_set_index(snd_seq_query_subscribe_t *info, int index);
355 int snd_seq_query_port_subscribers(snd_seq_t *seq, snd_seq_query_subscribe_t * subs);
361 * \defgroup SeqQueue Sequencer Queue Interface
362 * Sequencer Queue Interface
367 /** queue information container */
368 typedef struct _snd_seq_queue_info snd_seq_queue_info_t;
369 /** queue status container */
370 typedef struct _snd_seq_queue_status snd_seq_queue_status_t;
371 /** queue tempo container */
372 typedef struct _snd_seq_queue_tempo snd_seq_queue_tempo_t;
373 /** queue timer information container */
374 typedef struct _snd_seq_queue_timer snd_seq_queue_timer_t;
376 /** special queue ids */
377 #define SND_SEQ_QUEUE_DIRECT 253 /**< direct dispatch */
379 size_t snd_seq_queue_info_sizeof(void);
380 /** allocate a #snd_seq_queue_info_t container on stack */
381 #define snd_seq_queue_info_alloca(ptr) \
382 SND_ALLOCA(snd_seq_queue_info, ptr)
383 int snd_seq_queue_info_malloc(snd_seq_queue_info_t **ptr);
384 void snd_seq_queue_info_free(snd_seq_queue_info_t *ptr);
385 void snd_seq_queue_info_copy(snd_seq_queue_info_t *dst, const snd_seq_queue_info_t *src);
387 int snd_seq_queue_info_get_queue(const snd_seq_queue_info_t *info);
388 const char *snd_seq_queue_info_get_name(const snd_seq_queue_info_t *info);
389 int snd_seq_queue_info_get_owner(const snd_seq_queue_info_t *info);
390 int snd_seq_queue_info_get_locked(const snd_seq_queue_info_t *info);
391 unsigned int snd_seq_queue_info_get_flags(const snd_seq_queue_info_t *info);
393 void snd_seq_queue_info_set_name(snd_seq_queue_info_t *info, const char *name);
394 void snd_seq_queue_info_set_owner(snd_seq_queue_info_t *info, int owner);
395 void snd_seq_queue_info_set_locked(snd_seq_queue_info_t *info, int locked);
396 void snd_seq_queue_info_set_flags(snd_seq_queue_info_t *info, unsigned int flags);
398 int snd_seq_create_queue(snd_seq_t *seq, snd_seq_queue_info_t *info);
399 int snd_seq_alloc_named_queue(snd_seq_t *seq, const char *name);
400 int snd_seq_alloc_queue(snd_seq_t *handle);
401 int snd_seq_free_queue(snd_seq_t *handle, int q);
402 int snd_seq_get_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
403 int snd_seq_set_queue_info(snd_seq_t *seq, int q, snd_seq_queue_info_t *info);
404 int snd_seq_query_named_queue(snd_seq_t *seq, const char *name);
406 int snd_seq_get_queue_usage(snd_seq_t *handle, int q);
407 int snd_seq_set_queue_usage(snd_seq_t *handle, int q, int used);
411 size_t snd_seq_queue_status_sizeof(void);
412 /** allocate a #snd_seq_queue_status_t container on stack */
413 #define snd_seq_queue_status_alloca(ptr) \
414 SND_ALLOCA(snd_seq_queue_status, ptr)
415 int snd_seq_queue_status_malloc(snd_seq_queue_status_t **ptr);
416 void snd_seq_queue_status_free(snd_seq_queue_status_t *ptr);
417 void snd_seq_queue_status_copy(snd_seq_queue_status_t *dst, const snd_seq_queue_status_t *src);
419 int snd_seq_queue_status_get_queue(const snd_seq_queue_status_t *info);
420 int snd_seq_queue_status_get_events(const snd_seq_queue_status_t *info);
421 snd_seq_tick_time_t snd_seq_queue_status_get_tick_time(const snd_seq_queue_status_t *info);
422 const snd_seq_real_time_t *snd_seq_queue_status_get_real_time(const snd_seq_queue_status_t *info);
423 unsigned int snd_seq_queue_status_get_status(const snd_seq_queue_status_t *info);
425 int snd_seq_get_queue_status(snd_seq_t *handle, int q, snd_seq_queue_status_t *status);
429 size_t snd_seq_queue_tempo_sizeof(void);
430 /** allocate a #snd_seq_queue_tempo_t container on stack */
431 #define snd_seq_queue_tempo_alloca(ptr) \
432 SND_ALLOCA(snd_seq_queue_tempo, ptr)
433 int snd_seq_queue_tempo_malloc(snd_seq_queue_tempo_t **ptr);
434 void snd_seq_queue_tempo_free(snd_seq_queue_tempo_t *ptr);
435 void snd_seq_queue_tempo_copy(snd_seq_queue_tempo_t *dst, const snd_seq_queue_tempo_t *src);
437 int snd_seq_queue_tempo_get_queue(const snd_seq_queue_tempo_t *info);
438 unsigned int snd_seq_queue_tempo_get_tempo(const snd_seq_queue_tempo_t *info);
439 int snd_seq_queue_tempo_get_ppq(const snd_seq_queue_tempo_t *info);
440 void snd_seq_queue_tempo_set_tempo(snd_seq_queue_tempo_t *info, unsigned int tempo);
441 void snd_seq_queue_tempo_set_ppq(snd_seq_queue_tempo_t *info, int ppq);
443 int snd_seq_get_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
444 int snd_seq_set_queue_tempo(snd_seq_t *handle, int q, snd_seq_queue_tempo_t *tempo);
449 /** sequencer timer sources */
451 SND_SEQ_TIMER_ALSA = 0, /* ALSA timer */
452 SND_SEQ_TIMER_MIDI_CLOCK = 1, /* Midi Clock (CLOCK event) */
453 SND_SEQ_TIMER_MIDI_TICK = 2, /* Midi Timer Tick (TICK event */
454 } snd_seq_queue_timer_type_t;
456 size_t snd_seq_queue_timer_sizeof(void);
457 /** allocate a #snd_seq_queue_timer_t container on stack */
458 #define snd_seq_queue_timer_alloca(ptr) \
459 SND_ALLOCA(snd_seq_queue_timer, ptr)
460 int snd_seq_queue_timer_malloc(snd_seq_queue_timer_t **ptr);
461 void snd_seq_queue_timer_free(snd_seq_queue_timer_t *ptr);
462 void snd_seq_queue_timer_copy(snd_seq_queue_timer_t *dst, const snd_seq_queue_timer_t *src);
464 int snd_seq_queue_timer_get_queue(const snd_seq_queue_timer_t *info);
465 snd_seq_queue_timer_type_t snd_seq_queue_timer_get_type(const snd_seq_queue_timer_t *info);
466 const snd_timer_id_t *snd_seq_queue_timer_get_id(const snd_seq_queue_timer_t *info);
467 unsigned int snd_seq_queue_timer_get_resolution(const snd_seq_queue_timer_t *info);
469 void snd_seq_queue_timer_set_type(snd_seq_queue_timer_t *info, snd_seq_queue_timer_type_t type);
470 void snd_seq_queue_timer_set_id(snd_seq_queue_timer_t *info, const snd_timer_id_t *id);
471 void snd_seq_queue_timer_set_resolution(snd_seq_queue_timer_t *info, unsigned int resolution);
473 int snd_seq_get_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
474 int snd_seq_set_queue_timer(snd_seq_t *handle, int q, snd_seq_queue_timer_t *timer);
479 * \defgroup SeqEvent Sequencer Event API
480 * Sequencer Event API
485 snd_seq_event_t *snd_seq_create_event(void);
486 int snd_seq_free_event(snd_seq_event_t *ev);
487 ssize_t snd_seq_event_length(snd_seq_event_t *ev);
488 int snd_seq_event_output(snd_seq_t *handle, snd_seq_event_t *ev);
489 int snd_seq_event_output_buffer(snd_seq_t *handle, snd_seq_event_t *ev);
490 int snd_seq_event_output_direct(snd_seq_t *handle, snd_seq_event_t *ev);
491 int snd_seq_event_input(snd_seq_t *handle, snd_seq_event_t **ev);
492 int snd_seq_event_input_pending(snd_seq_t *seq, int fetch_sequencer);
493 int snd_seq_drain_output(snd_seq_t *handle);
494 int snd_seq_event_output_pending(snd_seq_t *seq);
495 int snd_seq_extract_output(snd_seq_t *handle, snd_seq_event_t **ev);
496 int snd_seq_drop_output(snd_seq_t *handle);
497 int snd_seq_drop_output_buffer(snd_seq_t *handle);
498 int snd_seq_drop_input(snd_seq_t *handle);
499 int snd_seq_drop_input_buffer(snd_seq_t *handle);
501 /** event removal conditionals */
502 typedef struct _snd_seq_remove_events snd_seq_remove_events_t;
504 /** Remove conditional flags */
505 #define SND_SEQ_REMOVE_INPUT (1<<0) /**< Flush input queues */
506 #define SND_SEQ_REMOVE_OUTPUT (1<<1) /**< Flush output queues */
507 #define SND_SEQ_REMOVE_DEST (1<<2) /**< Restrict by destination q:client:port */
508 #define SND_SEQ_REMOVE_DEST_CHANNEL (1<<3) /**< Restrict by channel */
509 #define SND_SEQ_REMOVE_TIME_BEFORE (1<<4) /**< Restrict to before time */
510 #define SND_SEQ_REMOVE_TIME_AFTER (1<<5) /**< Restrict to time or after */
511 #define SND_SEQ_REMOVE_TIME_TICK (1<<6) /**< Time is in ticks */
512 #define SND_SEQ_REMOVE_EVENT_TYPE (1<<7) /**< Restrict to event type */
513 #define SND_SEQ_REMOVE_IGNORE_OFF (1<<8) /**< Do not flush off events */
514 #define SND_SEQ_REMOVE_TAG_MATCH (1<<9) /**< Restrict to events with given tag */
516 size_t snd_seq_remove_events_sizeof(void);
517 /** allocate a #snd_seq_remove_events_t container on stack */
518 #define snd_seq_remove_events_alloca(ptr) \
519 SND_ALLOCA(snd_seq_remove_events, ptr)
520 int snd_seq_remove_events_malloc(snd_seq_remove_events_t **ptr);
521 void snd_seq_remove_events_free(snd_seq_remove_events_t *ptr);
522 void snd_seq_remove_events_copy(snd_seq_remove_events_t *dst, const snd_seq_remove_events_t *src);
524 unsigned int snd_seq_remove_events_get_condition(const snd_seq_remove_events_t *info);
525 int snd_seq_remove_events_get_queue(const snd_seq_remove_events_t *info);
526 const snd_seq_timestamp_t *snd_seq_remove_events_get_time(const snd_seq_remove_events_t *info);
527 const snd_seq_addr_t *snd_seq_remove_events_get_dest(const snd_seq_remove_events_t *info);
528 int snd_seq_remove_events_get_channel(const snd_seq_remove_events_t *info);
529 int snd_seq_remove_events_get_event_type(const snd_seq_remove_events_t *info);
530 int snd_seq_remove_events_get_tag(const snd_seq_remove_events_t *info);
532 void snd_seq_remove_events_set_condition(snd_seq_remove_events_t *info, unsigned int flags);
533 void snd_seq_remove_events_set_queue(snd_seq_remove_events_t *info, int queue);
534 void snd_seq_remove_events_set_time(snd_seq_remove_events_t *info, const snd_seq_timestamp_t *time);
535 void snd_seq_remove_events_set_dest(snd_seq_remove_events_t *info, const snd_seq_addr_t *addr);
536 void snd_seq_remove_events_set_channel(snd_seq_remove_events_t *info, int channel);
537 void snd_seq_remove_events_set_event_type(snd_seq_remove_events_t *info, int type);
538 void snd_seq_remove_events_set_tag(snd_seq_remove_events_t *info, int tag);
540 int snd_seq_remove_events(snd_seq_t *handle, snd_seq_remove_events_t *info);
545 * \defgroup SeqMisc Sequencer Miscellaneous
546 * Sequencer Mescellaneous
551 void snd_seq_set_bit(int nr, void *array);
552 int snd_seq_change_bit(int nr, void *array);
553 int snd_seq_get_bit(int nr, void *array);
559 * \defgroup SeqEvType Sequencer Event Type Checks
560 * Sequencer Event Type Checks
565 /* event type macros */
567 SND_SEQ_EVFLG_RESULT,
569 SND_SEQ_EVFLG_CONTROL,
571 SND_SEQ_EVFLG_SYSTEM,
572 SND_SEQ_EVFLG_MESSAGE,
573 SND_SEQ_EVFLG_CONNECTION,
574 SND_SEQ_EVFLG_SAMPLE,
581 SND_SEQ_EVFLG_VARIABLE,
582 SND_SEQ_EVFLG_VARUSR,
587 SND_SEQ_EVFLG_NOTE_ONEARG,
588 SND_SEQ_EVFLG_NOTE_TWOARG
592 SND_SEQ_EVFLG_QUEUE_NOARG,
593 SND_SEQ_EVFLG_QUEUE_TICK,
594 SND_SEQ_EVFLG_QUEUE_TIME,
595 SND_SEQ_EVFLG_QUEUE_VALUE
599 * Exported event type table
601 * This table is referred by snd_seq_ev_is_xxx.
603 extern const unsigned int snd_seq_event_types[];
605 #define _SND_SEQ_TYPE(x) (1<<(x)) /**< master type - 24bit */
606 #define _SND_SEQ_TYPE_OPT(x) ((x)<<24) /**< optional type - 8bit */
608 /** check the event type */
609 #define snd_seq_type_check(ev,x) (snd_seq_event_types[(ev)->type] & _SND_SEQ_TYPE(x))
611 /** event type check: result events */
612 #define snd_seq_ev_is_result_type(ev) \
613 snd_seq_type_check(ev, SND_SEQ_EVFLG_RESULT)
614 /** event type check: note events */
615 #define snd_seq_ev_is_note_type(ev) \
616 snd_seq_type_check(ev, SND_SEQ_EVFLG_NOTE)
617 /** event type check: control events */
618 #define snd_seq_ev_is_control_type(ev) \
619 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONTROL)
620 /** event type check: channel specific events */
621 #define snd_seq_ev_is_channel_type(ev) \
622 (snd_seq_event_types[(ev)->type] & (_SND_SEQ_TYPE(SND_SEQ_EVFLG_NOTE) | _SND_SEQ_TYPE(SND_SEQ_EVFLG_CONTROL)))
624 /** event type check: queue control events */
625 #define snd_seq_ev_is_queue_type(ev) \
626 snd_seq_type_check(ev, SND_SEQ_EVFLG_QUEUE)
627 /** event type check: system status messages */
628 #define snd_seq_ev_is_message_type(ev) \
629 snd_seq_type_check(ev, SND_SEQ_EVFLG_MESSAGE)
630 /** event type check: system status messages */
631 #define snd_seq_ev_is_subscribe_type(ev) \
632 snd_seq_type_check(ev, SND_SEQ_EVFLG_CONNECTION)
633 /** event type check: sample messages */
634 #define snd_seq_ev_is_sample_type(ev) \
635 snd_seq_type_check(ev, SND_SEQ_EVFLG_SAMPLE)
636 /** event type check: user-defined messages */
637 #define snd_seq_ev_is_user_type(ev) \
638 snd_seq_type_check(ev, SND_SEQ_EVFLG_USERS)
639 /** event type check: instrument layer events */
640 #define snd_seq_ev_is_instr_type(ev) \
641 snd_seq_type_check(ev, SND_SEQ_EVFLG_INSTR)
642 /** event type check: fixed length events */
643 #define snd_seq_ev_is_fixed_type(ev) \
644 snd_seq_type_check(ev, SND_SEQ_EVFLG_FIXED)
645 /** event type check: variable length events */
646 #define snd_seq_ev_is_variable_type(ev) \
647 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARIABLE)
648 /** event type check: user pointer events */
649 #define snd_seq_ev_is_varusr_type(ev) \
650 snd_seq_type_check(ev, SND_SEQ_EVFLG_VARUSR)
651 /** event type check: ipc events */
652 #define snd_seq_ev_is_varipc_type(ev) \
653 snd_seq_type_check(ev, SND_SEQ_EVFLG_IPC)
654 /** event type check: reserved for kernel */
655 #define snd_seq_ev_is_reserved(ev) \
656 (! snd_seq_event_types[(ev)->type])
659 * macros to check event flags
662 #define snd_seq_ev_is_prior(ev) \
663 (((ev)->flags & SND_SEQ_PRIORITY_MASK) == SND_SEQ_PRIORITY_HIGH)
665 /** get the data length type */
666 #define snd_seq_ev_length_type(ev) \
667 ((ev)->flags & SND_SEQ_EVENT_LENGTH_MASK)
668 /** fixed length events */
669 #define snd_seq_ev_is_fixed(ev) \
670 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_FIXED)
671 /** variable length events */
672 #define snd_seq_ev_is_variable(ev) \
673 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIABLE)
674 /** variable length on user-space */
675 #define snd_seq_ev_is_varusr(ev) \
676 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARUSR)
677 /** variable length on IPC shm */
678 #define snd_seq_ev_is_varipc(ev) \
679 (snd_seq_ev_length_type(ev) == SND_SEQ_EVENT_LENGTH_VARIPC)
681 /** time-stamp type */
682 #define snd_seq_ev_timestamp_type(ev) \
683 ((ev)->flags & SND_SEQ_TIME_STAMP_MASK)
684 /** event is in tick time */
685 #define snd_seq_ev_is_tick(ev) \
686 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_TICK)
687 /** event is in real-time */
688 #define snd_seq_ev_is_real(ev) \
689 (snd_seq_ev_timestamp_type(ev) == SND_SEQ_TIME_STAMP_REAL)
691 /** time-mode type */
692 #define snd_seq_ev_timemode_type(ev) \
693 ((ev)->flags & SND_SEQ_TIME_MODE_MASK)
694 /** scheduled in absolute time */
695 #define snd_seq_ev_is_abstime(ev) \
696 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_ABS)
697 /** scheduled in relative time */
698 #define snd_seq_ev_is_reltime(ev) \
699 (snd_seq_ev_timemode_type(ev) == SND_SEQ_TIME_MODE_REL)
701 /** direct dispatched events */
702 #define snd_seq_ev_is_direct(ev) \
703 ((ev)->queue == SND_SEQ_QUEUE_DIRECT)
711 #endif /* __ALSA_SEQ_H */