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