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