OSDN Git Service

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