OSDN Git Service

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