2
* Copyright (c) 2004 by Hannu Savolainen < hannu@opensound.com>
4
* This library is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 2.1 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public
14
* License along with this library; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
static int nports = 0;
23
typedef struct _snd_seq_port_subscribe
26
} snd_seq_port_subscribe_t;
28
typedef struct _snd_seq_queue_tempo
31
} snd_seq_queue_tempo_t;
33
typedef struct _snd_seq_system_info
36
} snd_seq_system_info_t;
38
struct _snd_seq_remove_events
43
struct _snd_seq_query_subscribe
49
* \brief Open the ALSA sequencer
51
* \param seqp Pointer to a snd_seq_t pointer. This pointer must be
52
* kept and passed to most of the other sequencer functions.
53
* \param name The sequencer's "name". This is \em not a name you make
54
* up for your own purposes; it has special significance to the ALSA
55
* library. Usually you need to pass \c "default" here.
56
* \param streams The read/write mode of the sequencer. Can be one of
58
* - #SND_SEQ_OPEN_OUTPUT - open the sequencer for output only
59
* - #SND_SEQ_OPEN_INPUT - open the sequencer for input only
60
* - #SND_SEQ_OPEN_DUPLEX - open the sequencer for output and input
61
* \note Internally, these are translated to \c O_WRONLY, \c O_RDONLY and
62
* \c O_RDWR respectively and used as the second argument to the C library
64
* \param mode Optional modifier. Can be either 0, or
65
* #SND_SEQ_NONBLOCK, which will make read/write operations
66
* non-blocking. This can also be set later using #snd_seq_nonblock().
67
* \return 0 on success otherwise a negative error code
69
* Creates a new handle and opens a connection to the kernel
70
* sequencer interface.
71
* After a client is created successfully, an event
72
* with #SND_SEQ_EVENT_CLIENT_START is broadcast to announce port.
74
* \sa snd_seq_open_lconf(), snd_seq_close(), snd_seq_type(), snd_seq_name(),
75
* snd_seq_nonblock(), snd_seq_client_id()
78
snd_seq_open (snd_seq_t ** seqp, const char *name, int streams, int mode)
82
static int instance = 0;
84
char *fname = "/dev/midi", *envname = NULL, tmp[128];
88
dbg_printf ("snd_seq_open(name='%s', streams=%d, mode=%x)\n", name, streams,
91
if (!alib_appcheck ())
96
sprintf (tmp, "%s_mididev%d", alib_appname, instance);
98
if ((envname = getenv (tmp)) != NULL)
105
fprintf (stderr, "salsa: snd_seq_open doesn't support streams=%d\n",
111
if ((seq = malloc (sizeof (*seq))) == NULL)
114
dbg_printf ("Created sequencer seq=%x\n", seq);
116
memset (seq, 0, sizeof (*seq));
120
case SND_SEQ_OPEN_INPUT:
122
dbg_printf ("Open SND_SEQ_OPEN_INPUT\n");
124
case SND_SEQ_OPEN_OUTPUT:
126
dbg_printf ("Open SND_SEQ_OPEN_OUTPUT\n");
128
case SND_SEQ_OPEN_DUPLEX:
129
dbg_printf ("SND_SEQ_OPEN_DUPLEX\n");
134
fprintf (stderr, "snd_seq_open: Unknown stream %x\n", streams);
138
if ((seq->fd = open (fname, oss_mode, 0)) == -1)
146
"You can select another filename using environment variable %s_mididev%d\n",
147
alib_appname, instance);
152
seq->streams = streams;
153
seq->oss_mode = oss_mode;
155
if (streams == SND_SEQ_OPEN_INPUT || streams == SND_SEQ_OPEN_DUPLEX)
157
seq->parser = midiparser_create (midiparser_callback, seq);
158
if (seq->parser == NULL)
160
fprintf (stderr, "libsalsa: Can't create MIDI parser\n");
170
* \brief Close the sequencer
171
* \param handle Handle returned from #snd_seq_open()
172
* \return 0 on success otherwise a negative error code
174
* Closes the sequencer client and releases its resources.
175
* After a client is closed, an event with
176
* #SND_SEQ_EVENT_CLIENT_EXIT is broadcast to announce port.
177
* The connection between other clients are disconnected.
178
* Call this just before exiting your program.
180
* \sa snd_seq_close()
183
snd_seq_close (snd_seq_t * seq)
185
dbg_printf ("snd_seq_close(seq=%x)\n", seq);
192
* \brief Set nonblock mode
193
* \param seq sequencer handle
194
* \param nonblock 0 = block, 1 = nonblock mode
195
* \return 0 on success otherwise a negative error code
197
* Change the blocking mode of the given client.
198
* In block mode, the client falls into sleep when it fills the
199
* output memory pool with full events. The client will be woken up
200
* after a certain amount of free space becomes available.
205
snd_seq_nonblock (snd_seq_t * seq, int nonblock)
207
dbg_printf ("snd_seq_nonblock(seq=%x, nonblock=%d)\n", seq, nonblock);
209
seq->nonblock = nonblock;
214
* \brief create a sequencer port on the current client
215
* \param seq sequencer handle
216
* \param port port information for the new port
217
* \return 0 on success otherwise a negative error code
219
* Creates a sequencer port on the current client.
220
* The attributes of created port is specified in \a info argument.
222
* The client field in \a info argument is overwritten with the current client id.
223
* The port id to be created can be specified via #snd_seq_port_info_set_port_specified.
224
* You can get the created port id by reading the port pointer via #snd_seq_port_info_get_port.
226
* Each port has the capability bit-masks to specify the access capability
227
* of the port from other clients.
228
* The capability bit flags are defined as follows:
229
* - #SND_SEQ_PORT_CAP_READ Readable from this port
230
* - #SND_SEQ_PORT_CAP_WRITE Writable to this port.
231
* - #SND_SEQ_PORT_CAP_SYNC_READ For synchronization (not implemented)
232
* - #SND_SEQ_PORT_CAP_SYNC_WRITE For synchronization (not implemented)
233
* - #SND_SEQ_PORT_CAP_DUPLEX Read/write duplex access is supported
234
* - #SND_SEQ_PORT_CAP_SUBS_READ Read subscription is allowed
235
* - #SND_SEQ_PORT_CAP_SUBS_WRITE Write subscription is allowed
236
* - #SND_SEQ_PORT_CAP_SUBS_NO_EXPORT Subscription management from 3rd client is disallowed
238
* Each port has also the type bitmasks defined as follows:
239
* - #SND_SEQ_PORT_TYPE_SPECIFIC Hardware specific port
240
* - #SND_SEQ_PORT_TYPE_MIDI_GENERIC Generic MIDI device
241
* - #SND_SEQ_PORT_TYPE_MIDI_GM General MIDI compatible device
242
* - #SND_SEQ_PORT_TYPE_MIDI_GS GS compatible device
243
* - #SND_SEQ_PORT_TYPE_MIDI_XG XG compatible device
244
* - #SND_SEQ_PORT_TYPE_MIDI_MT32 MT-32 compatible device
245
* - #SND_SEQ_PORT_TYPE_SYNTH Synth device
246
* - #SND_SEQ_PORT_TYPE_DIRECT_SAMPLE Sampling device (supporting download)
247
* - #SND_SEQ_PORT_TYPE_SAMPLE Sampling device (sample can be downloaded at any time)
248
* - #SND_SEQ_PORT_TYPE_APPLICATION Application (sequencer/editor)
250
* A port may contain specific midi channels, midi voices and synth voices.
251
* These values could be zero as default.
253
* \sa snd_seq_delete_port(), snd_seq_get_port_info(),
254
* snd_seq_create_simple_port()
257
snd_seq_create_port (snd_seq_t * seq, snd_seq_port_info_t * port)
259
dbg_printf ("snd_seq_create_port(seq=%x, port=%x)\n", seq, port);
261
port->port = nports++;
266
* \brief Get the client id
267
* \param seq sequencer handle
268
* \return the client id
270
* Returns the id of the specified client.
271
* If an error occurs, function returns the negative error code.
272
* A client id is necessary to inquiry or to set the client information.
273
* A user client is assigned from 128 to 191.
278
snd_seq_client_id (snd_seq_t * seq)
280
static int client_id = 128;
282
dbg_printf ("snd_seq_client_id(seq=%x)=%d\n", seq, client_id);
288
* \brief Get client id of a client_info container
289
* \param info client_info container
292
* \sa snd_seq_get_client_info(), snd_seq_client_info_set_client(), snd_seq_client_id()
295
snd_seq_client_info_get_client (const snd_seq_client_info_t * info)
297
dbg_printf ("snd_seq_client_info_get_client()\n");
303
* \brief Get client type of a client_info container
304
* \param info client_info container
305
* \return client type
307
* The client type is either #SEQ_CLIENT_TYPE_KERNEL or #SEQ_CLIENT_TYPE_USER
308
* for kernel or user client respectively.
310
* \sa snd_seq_get_client_info()
312
snd_seq_client_type_t
313
snd_seq_client_info_get_type (const snd_seq_client_info_t * info)
315
dbg_printf ("snd_seq_client_info_get_type(infp=%x)\n", info);
317
return SND_SEQ_KERNEL_CLIENT; // TODO
321
* \brief Set the client id of a client_info container
322
* \param info client_info container
323
* \param client client id
325
* \sa snd_seq_get_client_info(), snd_seq_client_info_get_client()
328
snd_seq_client_info_set_client (snd_seq_client_info_t * info, int client)
330
dbg_printf ("snd_seq_client_info_set_client(%x, %d)\n", info, client);
332
info->client = client;
336
* \brief get size of #snd_seq_client_info_t
337
* \return size in bytes
340
snd_seq_client_info_sizeof ()
342
dbg_printf ("snd_seq_client_info_sizeof()\n");
344
return sizeof (snd_seq_client_info_t);
348
* \brief retrieve an event from sequencer
349
* \param seq sequencer handle
350
* \param ev event pointer to be stored
353
* Obtains an input event from sequencer.
354
* The event is created via snd_seq_create_event(), and its pointer is stored on * ev argument.
356
* This function firstly receives the event byte-stream data from sequencer
357
* as much as possible at once. Then it retrieves the first event record
358
* and store the pointer on ev.
359
* By calling this function sequentially, events are extracted from the input buffer.
361
* If there is no input from sequencer, function falls into sleep
362
* in blocking mode until an event is received,
363
* or returns \c -EAGAIN error in non-blocking mode.
364
* Occasionally, this function may return \c -ENOSPC error.
365
* This means that the input FIFO of sequencer overran, and some events are
367
* Once this error is returned, the input FIFO is cleared automatically.
369
* Function returns the byte size of remaining events on the input buffer
370
* if an event is successfully received.
371
* Application can determine from the returned value whether to call
372
* input once more or not.
374
* \sa snd_seq_event_input_pending(), snd_seq_drop_input()
377
snd_seq_event_input (snd_seq_t * seq, snd_seq_event_t ** evp)
379
static snd_seq_event_t *ev;
380
unsigned char buf[256];
383
dbg_printf2 ("snd_seq_event_input(seq=%x)\n", seq);
388
if (seq->nextevent < seq->nevents)
390
*evp = &seq->events[seq->nextevent++];
392
return (seq->nevents - seq->nextevent) * sizeof (snd_seq_event_t);
395
seq->nextevent = seq->nevents = 0;
396
memset (seq->events, 0, sizeof (seq->events));
398
// TODO Handling of nonblocking mode
399
if ((l = read (seq->fd, buf, sizeof (buf))) == -1)
402
midiparser_input_buf (seq->parser, buf, l);
409
* \brief output an event directly to the sequencer NOT through output buffer
410
* \param seq sequencer handle
411
* \param ev event to be output
412
* \return the byte size sent to sequencer or a negative error code
414
* This function sends an event to the sequencer directly not through the
415
* output buffer. When the event is a variable length event, a temporary
416
* buffer is allocated inside alsa-lib and the data is copied there before
419
* \sa snd_seq_event_output()
422
snd_seq_event_output_direct (snd_seq_t * seq, snd_seq_event_t * ev)
426
dbg_printf3 ("snd_seq_event_output_direct()\n");
428
if ((err = convert_event (seq, ev)) < 0)
430
if ((err = snd_seq_drain_output (seq)) < 0)
437
* \brief (DEPRECATED) free an event
439
* In the former version, this function was used to
440
* release the event pointer which was allocated by snd_seq_event_input().
441
* In the current version, the event record is not allocated, so
442
* you don't have to call this function any more.
445
snd_seq_free_event (snd_seq_event_t * ev)
451
* \brief obtain the current client information
452
* \param seq sequencer handle
453
* \param info the pointer to be stored
454
* \return 0 on success otherwise a negative error code
456
* Obtains the information of the current client stored on info.
457
* client and type fields are ignored.
459
* \sa snd_seq_get_any_client_info(), snd_seq_set_client_info(),
460
* snd_seq_query_next_client()
463
snd_seq_get_client_info (snd_seq_t * seq, snd_seq_client_info_t * info)
465
dbg_printf ("snd_seq_get_client_info(seq=%x, info=%x)\n", seq, info);
471
* \brief query the next matching port
472
* \param seq sequencer handle
473
* \param info query pattern and result
475
* Queries the next matching port on the client specified in
477
* The search begins at the next port specified in
478
* port field of \a info argument.
479
* For finding the first port at a certain client, give -1.
481
* If a matching port is found, its attributes are stored on
482
* \a info and function returns zero.
483
* Otherwise, a negative error code is returned.
485
* \sa snd_seq_get_port_info()
488
snd_seq_query_next_port (snd_seq_t * seq, snd_seq_port_info_t * info)
490
dbg_printf ("snd_seq_query_next_port()\n");
496
* \brief Set the name of a client_info container
497
* \param info client_info container
498
* \param name name string
500
* \sa snd_seq_get_client_info(), snd_seq_client_info_get_name(),
501
* snd_seq_set_client_name()
504
snd_seq_client_info_set_name (snd_seq_client_info_t * info, const char *name)
506
dbg_printf ("snd_seq_client_info_set_name(%s)\n", name);
508
strncpy (info->name, name, sizeof (info->name) - 1);
509
info->name[sizeof (info->name) - 1] = 0;
513
* \brief subscribe a port connection
514
* \param seq sequencer handle
515
* \param sub subscription information
516
* \return 0 on success otherwise a negative error code
518
* Subscribes a connection between two ports.
519
* The subscription information is stored in sub argument.
521
* \sa snd_seq_get_port_subscription(), snd_seq_unsubscribe_port(),
522
* snd_seq_connect_from(), snd_seq_connect_to()
525
snd_seq_subscribe_port (snd_seq_t * seq, snd_seq_port_subscribe_t * sub)
527
dbg_printf ("snd_seq_subscribe_port()\n");
533
* \brief get size of #snd_seq_port_subscribe_t
534
* \return size in bytes
537
snd_seq_port_subscribe_sizeof ()
539
return sizeof (snd_seq_port_subscribe_t);
543
* \brief Set sender address of a port_subscribe container
544
* \param info port_subscribe container
545
* \param addr sender address
547
* \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_sender()
550
snd_seq_port_subscribe_set_sender (snd_seq_port_subscribe_t * info,
551
const snd_seq_addr_t * addr)
553
dbg_printf ("snd_seq_port_subscribe_set_sender()\n");
557
* \brief Set destination address of a port_subscribe container
558
* \param info port_subscribe container
559
* \param addr destination address
561
* \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_dest()
564
snd_seq_port_subscribe_set_dest (snd_seq_port_subscribe_t * info,
565
const snd_seq_addr_t * addr)
567
dbg_printf ("snd_seq_port_subscribe_set_dest()\n");
571
* \brief Set the queue id of a port_subscribe container
572
* \param info port_subscribe container
575
* \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_queue()
578
snd_seq_port_subscribe_set_queue (snd_seq_port_subscribe_t * info, int q)
580
dbg_printf ("snd_seq_port_subscribe_set_queue()\n");
584
* \brief Set the real-time mode of a port_subscribe container
585
* \param info port_subscribe container
586
* \param val non-zero to enable
588
* \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_time_real()
591
snd_seq_port_subscribe_set_time_real (snd_seq_port_subscribe_t * info,
594
dbg_printf ("snd_seq_port_subscribe_set_time_real()\n");
598
* \brief Set the time-update mode of a port_subscribe container
599
* \param info port_subscribe container
600
* \param val non-zero to enable
602
* \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_time_update()
605
snd_seq_port_subscribe_set_time_update (snd_seq_port_subscribe_t * info, int
608
dbg_printf ("snd_seq_port_subscribe_set_time_update()\n");
616
* \brief get size of #snd_seq_port_info_t
617
* \return size in bytes
620
snd_seq_port_info_sizeof ()
622
return sizeof (snd_seq_port_info_t);
626
* \brief Get the capability bits of a port_info container
627
* \param info port_info container
628
* \return capability bits
630
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_capability()
633
snd_seq_port_info_get_capability (const snd_seq_port_info_t * info)
635
dbg_printf ("snd_seq_port_info_get_capability()\n");
637
return info->capability;
641
* \brief Get client/port address of a port_info container
642
* \param info port_info container
643
* \return client/port address pointer
645
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_addr()
647
const snd_seq_addr_t *
648
snd_seq_port_info_get_addr (const snd_seq_port_info_t * info)
650
dbg_printf ("snd_seq_port_info_get_addr(info=%x)\n", info);
656
* \brief set the capability bits of a port_info container
657
* \param info port_info container
658
* \param capability capability bits
660
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_capability()
663
snd_seq_port_info_set_capability (snd_seq_port_info_t * info,
664
unsigned int capability)
666
dbg_printf ("snd_seq_port_info_set_capability()\n");
670
* \brief Set the port-specified mode of a port_info container
671
* \param info port_info container
672
* \param val non-zero if specifying the port id at creation
674
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_port_specified()
677
snd_seq_port_info_set_port_specified (snd_seq_port_info_t * info, int val)
679
dbg_printf ("snd_seq_port_info_set_port_specified()\n");
683
* \brief Get the midi channels of a port_info container
684
* \param info port_info container
685
* \return number of midi channels (default 0)
687
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_midi_channels()
690
snd_seq_port_info_get_midi_channels (const snd_seq_port_info_t * info)
692
dbg_printf ("snd_seq_port_info_get_midi_channels(info=%x)=%d\n",
693
info, info->midi_channels);
695
return info->midi_channels;
699
* \brief set the midi channels of a port_info container
700
* \param info port_info container
701
* \param channels midi channels (default 0)
703
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_midi_channels()
706
snd_seq_port_info_set_midi_channels (snd_seq_port_info_t * info, int channels)
708
dbg_printf ("snd_seq_port_info_set_midi_channels(info=%x, channels=%d)\n",
710
info->midi_channels = channels;
714
* \brief Get the queue id to update timestamps
715
* \param info port_info container
716
* \return the queue id to get the timestamps
718
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamp_queue()
721
snd_seq_port_info_get_timestamp_queue (const snd_seq_port_info_t * info)
723
dbg_printf ("snd_seq_port_info_get_timestamp_queue(info=%x)\n", info);
729
* \brief Set the queue id for timestamping
730
* \param info port_info container
731
* \param queue the queue id to get timestamps
733
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamp_queue()
736
snd_seq_port_info_set_timestamp_queue (snd_seq_port_info_t * info, int queue)
738
dbg_printf ("snd_seq_port_info_set_timestamp_queue(info=%x, queue=%d)\n",
745
* \brief Get whether the time-stamping of the given port is real-time mode
746
* \param info port_info container
747
* \return 1 if the time-stamping is in the real-time mode
749
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamp_real()
752
snd_seq_port_info_get_timestamp_real (const snd_seq_port_info_t * info)
754
dbg_printf ("snd_seq_port_info_get_timestamp_real(info=%x)\n", info);
760
* \brief Set whether the timestime is updated in the real-time mode
761
* \param info port_info container
762
* \param enable non-zero if updating the timestamps in real-time mode
764
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamp_real()
767
snd_seq_port_info_set_timestamp_real (snd_seq_port_info_t * info, int enable)
769
dbg_printf ("snd_seq_port_info_set_timestamp_real(infp=%x, enable=%d)\n",
774
* \brief Get the time-stamping mode of the given port in a port_info container * \param info port_info container
775
* \return 1 if the port updates timestamps of incoming events
777
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamping()
780
snd_seq_port_info_get_timestamping (const snd_seq_port_info_t * info)
782
dbg_printf ("snd_seq_port_info_get_timestamping(info=%x)\n", info);
788
* \brief Set the time-stamping mode of the given port
789
* \param info port_info container
790
* \param enable non-zero if updating the timestamps of incoming events
792
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamping()
795
snd_seq_port_info_set_timestamping (snd_seq_port_info_t * info, int enable)
797
dbg_printf ("snd_seq_port_info_set_timestamping(info=%x, enable=%d)\n",
804
* \brief Set the name of a port_info container
805
* \param info port_info container
806
* \param name name string
808
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_name()
811
snd_seq_port_info_set_name (snd_seq_port_info_t * info, const char *name)
813
dbg_printf ("snd_seq_port_info_set_name()\n");
815
strncpy (info->name, name, sizeof (info->name));
819
* \brief Get the name of a port_info container
820
* \param info port_info container
821
* \return name string
823
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_name()
826
snd_seq_port_info_get_name (const snd_seq_port_info_t * info)
828
dbg_printf ("snd_seq_port_info_get_name()\n");
834
* \brief Get port id of a port_info container
835
* \param info port_info container
838
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_port()
841
snd_seq_port_info_get_port (const snd_seq_port_info_t * info)
843
dbg_printf ("snd_seq_port_info_get_port()\n");
849
* \brief Get the type bits of a port_info container
850
* \param info port_info container
851
* \return port type bits
853
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_type()
856
snd_seq_port_info_get_type (const snd_seq_port_info_t * info)
858
dbg_printf ("snd_seq_port_info_get_type()\n");
864
* \brief Set the client id of a port_info container
865
* \param info port_info container
866
* \param client client id
868
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_client()
871
snd_seq_port_info_set_client (snd_seq_port_info_t * info, int client)
873
dbg_printf ("snd_seq_port_info_set_client()\n");
877
* \brief Set the port id of a port_info container
878
* \param info port_info container
879
* \param port port id
881
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_port()
884
snd_seq_port_info_set_port (snd_seq_port_info_t * info, int port)
886
dbg_printf ("snd_seq_port_info_set_port()\n");
890
* \brief query the next matching client
891
* \param seq sequencer handle
892
* \param info query pattern and result
894
* Queries the next matching client with the given condition in
896
* The search begins at the client with an id one greater than
897
* client field in info.
898
* If name field in info is not empty, the client name is compared.
899
* If a matching client is found, its attributes are stored o
900
* info and returns zero.
901
* Otherwise returns a negative error code.
903
* \sa snd_seq_get_any_client_info()
906
snd_seq_query_next_client (snd_seq_t * seq, snd_seq_client_info_t * info)
908
dbg_printf ("snd_seq_query_next_client()\n");
914
* \brief set the current client information
915
* \param seq sequencer handle
916
* \param info the client info data to set
917
* \return 0 on success otherwise a negative error code
919
* Obtains the information of the current client stored on info.
920
* client and type fields are ignored.
922
* \sa snd_seq_get_client_info()
925
snd_seq_set_client_info (snd_seq_t * seq, snd_seq_client_info_t * info)
927
dbg_printf ("snd_seq_set_client_info(seq=%x, info=%x)\n", seq, info);
931
strcpy (seq->name, info->name);
932
ioctl (seq->fd, SNDCTL_SETNAME, seq->name);
933
ioctl (seq->fd, SNDCTL_SETSONG, seq->name);
940
* \brief check events in input buffer
941
* \return the byte size of remaining input events on input buffer.
943
* If events remain on the input buffer of user-space, function returns
944
* the total byte size of events on it.
945
* If fetch_sequencer argument is non-zero,
946
* this function checks the presence of events on sequencer FIFO
947
* When events exist, they are transferred to the input buffer,
948
* and the number of received events are returned.
949
* If fetch_sequencer argument is zero and
950
* no events remain on the input buffer, function simply returns zero.
952
* \sa snd_seq_event_input()
955
snd_seq_event_input_pending (snd_seq_t * seq, int fetch_sequencer)
957
dbg_printf ("snd_seq_event_input_pending()\n");
963
* \brief Get poll descriptors
964
* \param seq sequencer handle
965
* \param pfds array of poll descriptors
966
* \param space space in the poll descriptor array
967
* \param events polling events to be checked (\c POLLIN and \c POLLOUT)
968
* \return count of filled descriptors
970
* Get poll descriptors assigned to the sequencer handle.
971
* Since a sequencer handle can duplex streams, you need to set which direction(s)
972
* is/are polled in \a events argument. When \c POLLIN bit is specified,
973
* the incoming events to the ports are checked.
975
* To check the returned poll-events, call #snd_seq_poll_descriptors_revents()
976
* instead of reading the pollfd structs directly.
978
* \sa snd_seq_poll_descriptors_count(), snd_seq_poll_descriptors_revents()
981
snd_seq_poll_descriptors (snd_seq_t * seq, struct pollfd *pfds,
982
unsigned int space, short events)
984
dbg_printf ("snd_seq_poll_descriptors(seq=%x)\n", seq);
990
if (seq->oss_mode == O_WRONLY || seq->oss_mode == O_RDWR)
991
pfds->events = POLLOUT;
992
if (seq->oss_mode == O_RDONLY || seq->oss_mode == O_RDWR)
993
pfds->events = POLLIN;
1000
* \brief Returns the number of poll descriptors
1001
* \param seq sequencer handle
1002
* \param events the poll events to be checked (\c POLLIN and \c POLLOUT)
1003
* \return the number of poll descriptors.
1005
* Get the number of poll descriptors. The polling events to be checked
1006
* can be specified by the second argument. When both input and output
1007
* are checked, pass \c POLLIN|POLLOUT
1009
* \sa snd_seq_poll_descriptors()
1012
snd_seq_poll_descriptors_count (snd_seq_t * seq, short events)
1014
dbg_printf ("snd_seq_poll_descriptors_count(seq=%x, events=%x)\n",
1020
* \brief create a queue
1021
* \param seq sequencer handle
1022
* \param info queue information to initialize
1023
* \return the queue id (zero or positive) on success otherwise a negative error code
1025
* \sa snd_seq_alloc_queue()
1028
snd_seq_create_queue (snd_seq_t * seq, snd_seq_queue_info_t * info)
1030
dbg_printf ("snd_seq_create_queue()\n");
1036
* \brief simple subscription (w/o exclusive & time conversion)
1037
* \param myport the port id as sender
1038
* \param dest_client destination client id
1039
* \param dest_port destination port id
1040
* \return 0 on success or negative error code
1042
* Connect from the given receiver port in the current client
1043
* to the given destination client:port.
1045
* \sa snd_seq_subscribe_port(), snd_seq_disconnect_to()
1048
snd_seq_connect_to (snd_seq_t * seq, int myport, int dest_client,
1051
dbg_printf ("snd_seq_connect_to(%d->%d/%d)\n", myport, dest_client,
1058
* \brief simple subscription (w/o exclusive & time conversion)
1059
* \param myport the port id as receiver
1060
* \param src_client sender client id
1061
* \param src_port sender port id
1062
* \return 0 on success or negative error code
1064
* Connect from the given sender client:port to the given destination port in the
1067
* \sa snd_seq_subscribe_port(), snd_seq_disconnect_from()
1070
snd_seq_connect_from (snd_seq_t * seq, int myport, int src_client,
1074
("snd_seq_connect_from(seq=%x, myport=%d, src_client=%d, src_port=%d)\n",
1075
seq, myport, src_client, src_port);
1081
* \brief queue controls - start/stop/continue
1082
* \param seq sequencer handle
1083
* \param q queue id to control
1084
* \param type event type
1085
* \param value event value
1086
* \param ev event instance
1088
* This function sets up general queue control event and sends it.
1089
* To send at scheduled time, set the schedule in \a ev.
1090
* If \a ev is NULL, the event is composed locally and sent immediately
1091
* to the specified queue. In any cases, you need to call #snd_seq_drain_output()
1092
* appropriately to feed the event.
1094
* \sa snd_seq_alloc_queue()
1097
snd_seq_control_queue (snd_seq_t * seq, int q, int type, int value,
1098
snd_seq_event_t * ev)
1100
dbg_printf ("snd_seq_control_queue()\n");
1106
* \brief drain output buffer to sequencer
1107
* \param seq sequencer handle
1108
* \return 0 when all events are drained and sent to sequencer.
1109
* When events still remain on the buffer, the byte size of remaining
1110
* events are returned. On error a negative error code is returned.
1112
* This function drains all pending events on the output buffer.
1113
* The function returns immediately after the events are sent to the queues
1114
* regardless whether the events are processed or not.
1115
* To get synchronization with the all event processes, use
1116
* #snd_seq_sync_output_queue() after calling this function.
1118
* \sa snd_seq_event_output(), snd_seq_sync_output_queue()
1121
snd_seq_drain_output (snd_seq_t * seq)
1123
dbg_printf3 ("snd_seq_drain_output(seq=%x)\n", seq);
1130
* \brief remove all events on output buffer
1131
* \param seq sequencer handle
1133
* Removes all events on both user-space output buffer and
1134
* output memory pool on kernel.
1136
* \sa snd_seq_drain_output(), snd_seq_drop_output_buffer(), snd_seq_remove_events()
1139
snd_seq_drop_output (snd_seq_t * seq)
1141
dbg_printf ("snd_seq_drop_output()\n");
1147
* \brief output an event
1148
* \param seq sequencer handle
1149
* \param ev event to be output
1150
* \return the number of remaining events or a negative error code
1152
* An event is once expanded on the output buffer.
1153
* The output buffer will be drained automatically if it becomes full.
1155
* If events remain unprocessed on output buffer before drained,
1156
* the size of total byte data on output buffer is returned.
1157
* If the output buffer is empty, this returns zero.
1159
* \sa snd_seq_event_output_direct(), snd_seq_event_output_buffer(),
1160
* snd_seq_event_output_pending(), snd_seq_drain_output(),
1161
* snd_seq_drop_output(), snd_seq_extract_output(),
1162
* snd_seq_remove_events()
1165
snd_seq_event_output (snd_seq_t * seq, snd_seq_event_t * ev)
1167
dbg_printf3 ("snd_seq_event_output(seq=%x, ev=%x)\n", seq, ev);
1169
return convert_event (seq, ev);
1173
* \brief delete the specified queue
1174
* \param seq sequencer handle
1175
* \param q queue id to delete
1176
* \return 0 on success otherwise a negative error code
1178
* \sa snd_seq_alloc_queue()
1181
snd_seq_free_queue (snd_seq_t * seq, int q)
1183
dbg_printf ("snd_seq_free_queue()\n");
1189
* \brief obtain the information of the given client
1190
* \param seq sequencer handle
1191
* \param client client id
1192
* \param info the pointer to be stored
1193
* \return 0 on success otherwise a negative error code
1195
* Obtains the information of the client with a client id specified by
1197
* The obtained information is written on info parameter.
1199
* \sa snd_seq_get_client_info()
1202
snd_seq_get_any_client_info (snd_seq_t * seq, int client,
1203
snd_seq_client_info_t * info)
1205
dbg_printf ("snd_seq_get_any_client_info()\n");
1207
strcpy (info->name, seq->name);
1213
* \brief obtain the information of a port on an arbitrary client
1214
* \param seq sequencer handle
1215
* \param client client id to get
1216
* \param port port id to get
1217
* \param info pointer information returns
1218
* \return 0 on success otherwise a negative error code
1220
* \sa snd_seq_get_port_info()
1223
snd_seq_get_any_port_info (snd_seq_t * seq, int client, int port,
1224
snd_seq_port_info_t * info)
1226
dbg_printf ("snd_seq_get_any_port_info()\n");
1232
* \brief allocate an empty #snd_seq_port_info_t using standard malloc
1233
* \param ptr returned pointer
1234
* \return 0 on success otherwise negative error code
1237
snd_seq_port_info_malloc (snd_seq_port_info_t ** ptr)
1239
snd_seq_port_info_t *p;
1241
dbg_printf ("snd_seq_port_info_malloc()\n");
1243
if ((p = malloc (sizeof (*p))) == NULL)
1252
* \brief frees a previously allocated #snd_seq_port_info_t
1253
* \param pointer to object to free
1256
snd_seq_port_info_free (snd_seq_port_info_t * obj)
1262
* \brief allocate an empty #snd_seq_queue_tempo_t using standard malloc
1263
* \param ptr returned pointer
1264
* \return 0 on success otherwise negative error code
1267
snd_seq_queue_tempo_malloc (snd_seq_queue_tempo_t ** ptr)
1270
*ptr = calloc (1, sizeof (snd_seq_queue_tempo_t));
1271
dbg_printf ("snd_seq_queue_tempo_malloc()=%x\n", *ptr);
1278
* \brief frees a previously allocated #snd_seq_queue_tempo_t
1279
* \param pointer to object to free
1282
snd_seq_queue_tempo_free (snd_seq_queue_tempo_t * obj)
1284
dbg_printf ("snd_seq_queue_tempo_free(%x)\n", obj);
1289
* \brief Set the ppq of a queue_status container
1290
* \param info queue_status container
1291
* \param ppq ppq value
1293
* \sa snd_seq_get_queue_tempo()
1296
snd_seq_queue_tempo_set_ppq (snd_seq_queue_tempo_t * info, int ppq)
1298
dbg_printf ("snd_seq_queue_tempo_set_ppq(info=%x, %d)\n", info, ppq);
1302
* \brief Set the tempo of a queue_status container
1303
* \param info queue_status container
1304
* \param tempo tempo value
1306
* \sa snd_seq_get_queue_tempo()
1309
snd_seq_queue_tempo_set_tempo (snd_seq_queue_tempo_t * info,
1312
dbg_printf ("snd_seq_queue_tempo_set_tempo(info=%x, %d)\n", info, tempo);
1316
* \brief get size of #snd_seq_queue_tempo_t
1317
* \return size in bytes
1320
snd_seq_queue_tempo_sizeof ()
1322
return sizeof (snd_seq_queue_tempo_t);
1326
* \brief set the queue timer information
1327
* \param seq sequencer handle
1328
* \param q queue id to change the timer
1329
* \param timer timer information
1330
* \return 0 on success otherwise a negative error code
1332
* \sa snd_seq_get_queue_timer()
1335
snd_seq_set_queue_timer (snd_seq_t * seq, int q,
1336
snd_seq_queue_timer_t * timer)
1338
dbg_printf ("snd_seq_get_queue_timer(seq=%x, q=%d, timer=%X)\n", seq, q,
1340
return -ENXIO; // TODO
1345
* \brief Opens a new connection to the timer query interface.
1346
* \param timer Returned handle (NULL if not wanted)
1347
* \param name ASCII identifier of the RawMidi handle
1348
* \param mode Open mode
1349
* \return 0 on success otherwise a negative error code
1351
* Opens a new connection to the RawMidi interface specified with
1352
* an ASCII identifier and mode.
1355
snd_timer_query_open (snd_timer_query_t ** timer, const char *name, int mode)
1357
dbg_printf ("snd_timer_query_open(name=%s, mode=%x)\n", name, mode);
1358
return -ENXIO; // TODO
1362
* \brief obtain the current tempo of the queue
1363
* \param seq sequencer handle
1364
* \param q queue id to be queried
1365
* \param tempo pointer to store the current tempo
1366
* \return 0 on success otherwise a negative error code
1368
* \sa snd_seq_set_queue_tempo()
1371
snd_seq_get_queue_tempo (snd_seq_t * seq, int q,
1372
snd_seq_queue_tempo_t * tempo)
1374
dbg_printf ("snd_seq_get_queue_tempo(seq=%x, q=%d, tempo=%x)\n", seq, q,
1381
* \brief allocate an empty #snd_seq_client_info_t using standard malloc
1382
* \param ptr returned pointer
1383
* \return 0 on success otherwise negative error code
1386
snd_seq_client_info_malloc (snd_seq_client_info_t ** ptr)
1388
dbg_printf ("snd_seq_client_info_malloc()\n");
1390
*ptr = malloc (sizeof (snd_seq_client_info_t));
1397
* \brief frees a previously allocated #snd_seq_client_info_t
1398
* \param pointer to object to free
1401
snd_seq_client_info_free (snd_seq_client_info_t * obj)
1403
dbg_printf ("snd_seq_client_info_free()\n");
1409
* \brief Get the name of a client_info container
1410
* \param info client_info container
1411
* \return name string
1413
* \sa snd_seq_get_client_info(), snd_seq_client_info_set_name()
1416
snd_seq_client_info_get_name (snd_seq_client_info_t * info)
1418
dbg_printf ("snd_seq_client_info_get_name()\n");
1419
return "OSS seq client";
1423
* \brief Get the number of opened ports of a client_info container
1424
* \param info client_info container
1425
* \return number of opened ports
1427
* \sa snd_seq_get_client_info()
1430
snd_seq_client_info_get_num_ports (const snd_seq_client_info_t * info)
1432
dbg_printf ("snd_seq_client_info_get_num_ports()\n");
1438
* \brief Get size of #snd_seq_system_info_t
1439
* \return size in bytes
1442
snd_seq_system_info_sizeof ()
1444
return sizeof (snd_seq_system_info_t);
1449
* \brief Allocate an empty #snd_seq_system_info_t using standard malloc
1450
* \param ptr returned pointer
1451
* \return 0 on success otherwise negative error code
1454
snd_seq_system_info_malloc (snd_seq_system_info_t ** ptr)
1456
dbg_printf ("snd_seq_system_info_malloc()\n");
1458
*ptr = malloc (sizeof (snd_seq_system_info_t));
1465
* \brief Frees a previously allocated #snd_seq_system_info_t
1466
* \param pointer to object to free
1469
snd_seq_system_info_free (snd_seq_system_info_t * obj)
1475
* \brief obtain the sequencer system information
1476
* \param seq sequencer handle
1477
* \param info the pointer to be stored
1478
* \return 0 on success otherwise a negative error code
1480
* Stores the global system information of ALSA sequencer system.
1481
* The returned data contains
1482
* the maximum available numbers of queues, clients, ports and channels.
1485
snd_seq_system_info (snd_seq_t * seq, snd_seq_system_info_t * info)
1487
dbg_printf ("snd_seq_system_info()\n");
1493
* \brief Get maximum number of clients
1494
* \param info #snd_seq_system_info_t container
1495
* \return maximum number of clients
1497
* \sa snd_seq_system_info()
1500
snd_seq_system_info_get_clients (const snd_seq_system_info_t * info)
1502
dbg_printf ("snd_seq_system_info_get_clients()\n");
1508
* \brief Get maximum number of queues
1509
* \param info #snd_seq_system_info_t container
1510
* \return maximum number of queues
1512
* \sa snd_seq_system_info()
1515
snd_seq_system_info_get_queues (const snd_seq_system_info_t * info)
1517
dbg_printf ("snd_seq_system_info_get_queues(info=%x)\n", info);
1523
* \brief Get maximum number of ports
1524
* \param info #snd_seq_system_info_t container
1525
* \return maximum number of ports
1527
* \sa snd_seq_system_info()
1530
snd_seq_system_info_get_ports (const snd_seq_system_info_t * info)
1532
dbg_printf ("snd_seq_system_info_get_ports()\n");
1538
* \brief allocate a queue with the specified name
1539
* \param seq sequencer handle
1540
* \param name the name of the new queue
1541
* \return the queue id (zero or positive) on success otherwise a negative error code
1543
* \sa snd_seq_alloc_queue()
1546
snd_seq_alloc_named_queue (snd_seq_t * seq, const char *name)
1548
dbg_printf ("snd_seq_alloc_named_queue(seq=%x, name=%s)\n", seq, name);
1555
* \brief Get client id of a port_info container
1556
* \param info port_info container
1559
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_client()
1562
snd_seq_port_info_get_client (const snd_seq_port_info_t * info)
1564
dbg_printf ("snd_seq_port_info_get_client()\n");
1570
* \brief Get the port-specified mode of a port_info container
1571
* \param info port_info container
1572
* \return 1 if port id is specified at creation
1574
* \sa snd_seq_get_port_info(), snd_seq_port_info_set_port_specified()
1577
snd_seq_port_info_get_port_specified (const snd_seq_port_info_t * info)
1579
dbg_printf ("snd_seq_port_info_get_port_specified()\n");
1585
* \brief Get the type bits of a port_info container
1586
* \param info port_info container
1587
* \return port type bits
1589
* \sa snd_seq_get_port_info(), snd_seq_port_info_get_type()
1592
snd_seq_port_info_set_type (snd_seq_port_info_t * info, unsigned int type)
1594
dbg_printf ("snd_seq_port_info_set_type(%u)\n", type);
1599
* \brief Get the ppq of a queue_status container
1600
* \param info queue_status container
1603
* \sa snd_seq_get_queue_tempo()
1606
snd_seq_queue_tempo_get_ppq (const snd_seq_queue_tempo_t * info)
1608
dbg_printf ("snd_seq_queue_tempo_get_ppq()\n");
1615
* \brief Get the tempo of a queue_status container
1616
* \param info queue_status container
1617
* \return tempo value
1619
* \sa snd_seq_get_queue_tempo()
1622
snd_seq_queue_tempo_get_tempo (const snd_seq_queue_tempo_t * info)
1624
dbg_printf ("snd_seq_queue_tempo_get_tempo()\n");
1630
* \brief set the tempo of the queue
1631
* \param seq sequencer handle
1632
* \param q queue id to change the tempo
1633
* \param tempo tempo information
1634
* \return 0 on success otherwise a negative error code
1636
* \sa snd_seq_get_queue_tempo()
1639
snd_seq_set_queue_tempo (snd_seq_t * seq, int q,
1640
snd_seq_queue_tempo_t * tempo)
1642
dbg_printf ("snd_seq_set_queue_tempo(seq=%x, q=%d, tempo=%x)\n", seq, q,
1649
* \brief allocate a queue
1650
* \param seq sequencer handle
1651
* \return the queue id (zero or positive) on success otherwise a negative error code
1653
* \sa snd_seq_alloc_named_queue(), snd_seq_create_queue(), snd_seq_free_queue(),
1654
* snd_seq_get_queue_info()
1657
snd_seq_alloc_queue (snd_seq_t * seq)
1659
static int queue_num = 0;
1660
dbg_printf ("snd_seq_alloc_queue(seq=%x)=%d\n", seq, queue_num);
1665
#define FIXED_EV(x) (_SND_SEQ_TYPE(SND_SEQ_EVFLG_FIXED) | _SND_SEQ_TYPE(x))
1667
/** Event types conversion array */
1668
const unsigned int snd_seq_event_types[256] = {
1669
[SND_SEQ_EVENT_SYSTEM...SND_SEQ_EVENT_RESULT]
1670
= FIXED_EV (SND_SEQ_EVFLG_RESULT),
1671
[SND_SEQ_EVENT_NOTE]
1673
FIXED_EV (SND_SEQ_EVFLG_NOTE) |
1674
_SND_SEQ_TYPE_OPT (SND_SEQ_EVFLG_NOTE_TWOARG),
1675
[SND_SEQ_EVENT_NOTEON...SND_SEQ_EVENT_KEYPRESS] =
1676
FIXED_EV (SND_SEQ_EVFLG_NOTE),
1677
[SND_SEQ_EVENT_CONTROLLER...SND_SEQ_EVENT_REGPARAM] =
1678
FIXED_EV (SND_SEQ_EVFLG_CONTROL),
1679
[SND_SEQ_EVENT_START...SND_SEQ_EVENT_STOP] = FIXED_EV (SND_SEQ_EVFLG_QUEUE),
1680
[SND_SEQ_EVENT_SETPOS_TICK]
1682
FIXED_EV (SND_SEQ_EVFLG_QUEUE) |
1683
_SND_SEQ_TYPE_OPT (SND_SEQ_EVFLG_QUEUE_TICK),
1684
[SND_SEQ_EVENT_SETPOS_TIME] =
1685
FIXED_EV (SND_SEQ_EVFLG_QUEUE) |
1686
_SND_SEQ_TYPE_OPT (SND_SEQ_EVFLG_QUEUE_TIME),
1687
[SND_SEQ_EVENT_TEMPO...SND_SEQ_EVENT_SYNC_POS] =
1688
FIXED_EV (SND_SEQ_EVFLG_QUEUE) |
1689
_SND_SEQ_TYPE_OPT (SND_SEQ_EVFLG_QUEUE_VALUE),
1690
[SND_SEQ_EVENT_TUNE_REQUEST...SND_SEQ_EVENT_SENSING] =
1691
FIXED_EV (SND_SEQ_EVFLG_NONE),
1692
[SND_SEQ_EVENT_ECHO...SND_SEQ_EVENT_OSS] =
1693
FIXED_EV (SND_SEQ_EVFLG_RAW) | FIXED_EV (SND_SEQ_EVFLG_SYSTEM),
1694
[SND_SEQ_EVENT_CLIENT_START...SND_SEQ_EVENT_PORT_CHANGE] =
1695
FIXED_EV (SND_SEQ_EVFLG_MESSAGE),
1696
[SND_SEQ_EVENT_PORT_SUBSCRIBED...SND_SEQ_EVENT_PORT_UNSUBSCRIBED] =
1697
FIXED_EV (SND_SEQ_EVFLG_CONNECTION),
1698
[SND_SEQ_EVENT_USR0...SND_SEQ_EVENT_USR9] =
1699
FIXED_EV (SND_SEQ_EVFLG_RAW) | FIXED_EV (SND_SEQ_EVFLG_USERS),
1700
[SND_SEQ_EVENT_SYSEX...SND_SEQ_EVENT_BOUNCE] =
1701
_SND_SEQ_TYPE (SND_SEQ_EVFLG_VARIABLE),
1702
[SND_SEQ_EVENT_USR_VAR0...SND_SEQ_EVENT_USR_VAR4] =
1703
_SND_SEQ_TYPE (SND_SEQ_EVFLG_VARIABLE) |
1704
_SND_SEQ_TYPE (SND_SEQ_EVFLG_USERS),
1705
[SND_SEQ_EVENT_NONE] = FIXED_EV (SND_SEQ_EVFLG_NONE),
1709
* \brief obtain the running state of the queue
1710
* \param seq sequencer handle
1711
* \param q queue id to query
1712
* \param status pointer to store the current status
1713
* \return 0 on success otherwise a negative error code
1715
* Obtains the running state of the specified queue q.
1718
snd_seq_get_queue_status (snd_seq_t * seq, int q,
1719
snd_seq_queue_status_t * status)
1721
dbg_printf ("snd_seq_get_queue_status(seq=%x. q=%d)\n", seq, q);
1727
* \brief allocate an empty #snd_seq_queue_status_t using standard malloc
1728
* \param ptr returned pointer
1729
* \return 0 on success otherwise negative error code
1732
snd_seq_queue_status_malloc (snd_seq_queue_status_t ** ptr)
1734
dbg_printf ("snd_seq_queue_status_malloc()\n");
1735
*ptr = calloc (1, sizeof (snd_seq_queue_status_t));
1736
dbg_printf ("snd_seq_queue_status_malloc()=%x\n", *ptr);
1743
* \brief frees a previously allocated #snd_seq_queue_status_t
1744
* \param pointer to object to free
1747
snd_seq_queue_status_free (snd_seq_queue_status_t * obj)
1749
dbg_printf ("snd_seq_queue_status_free(%x)\n", obj);
1755
* \brief Get the tick time of a queue_status container
1756
* \param info queue_status container
1759
* \sa snd_seq_get_queue_status()
1762
snd_seq_queue_status_get_tick_time (const snd_seq_queue_status_t * info)
1764
dbg_printf ("snd_seq_queue_status_get_tick_time(info=%x)\n", info);
1770
* \brief get size of #snd_seq_remove_events_t
1771
* \return size in bytes
1774
snd_seq_remove_events_sizeof ()
1776
return sizeof (snd_seq_remove_events_t);
1780
* \brief allocate an empty #snd_seq_remove_events_t using standard malloc
1781
* \param ptr returned pointer
1782
* \return 0 on success otherwise negative error code
1785
snd_seq_remove_events_malloc (snd_seq_remove_events_t ** ptr)
1788
*ptr = calloc (1, sizeof (snd_seq_remove_events_t));
1789
dbg_printf ("snd_seq_remove_events_malloc()=%x\n", *ptr);
1796
* \brief frees a previously allocated #snd_seq_remove_events_t
1797
* \param pointer to object to free
1800
snd_seq_remove_events_free (snd_seq_remove_events_t * obj)
1806
* \brief Set the removal condition bits
1807
* \param info remove_events container
1808
* \param flags removal condition bits
1810
* \sa snd_seq_remove_events()
1813
snd_seq_remove_events_set_condition (snd_seq_remove_events_t * info,
1816
dbg_printf ("snd_seq_remove_events_set_condition(rmp=%x, flags=%lu)\n",
1821
* \brief Set the queue as removal condition
1822
* \param info remove_events container
1823
* \param queue queue id
1825
* \sa snd_seq_remove_events()
1828
snd_seq_remove_events_set_queue (snd_seq_remove_events_t * info, int queue)
1830
dbg_printf ("snd_seq_remove_events_set_queue(rmp=%x, q=%d)\n", info, queue);
1834
* \brief remove events on input/output buffers and pools
1835
* \param seq sequencer handle
1836
* \param rmp remove event container
1838
* Removes matching events with the given condition from input/output buffers
1840
* The removal condition is specified in \a rmp argument.
1842
* \sa snd_seq_event_output(), snd_seq_drop_output(), snd_seq_reset_pool_output()
1845
snd_seq_remove_events (snd_seq_t * seq, snd_seq_remove_events_t * rmp)
1847
dbg_printf ("snd_seq_remove_events(seq=%x, rmp=%x)\n", seq, rmp);
1854
* \brief clear input buffer and and remove events in sequencer queue
1855
* \param seq sequencer handle
1857
* \sa snd_seq_drop_input_buffer(), snd_seq_remove_events()
1860
snd_seq_drop_input (snd_seq_t * seq)
1862
dbg_printf ("snd_seq_drop_input(seq=%x)\n", seq);
1868
* \brief remove all events on user-space output buffer
1869
* \param seq sequencer handle
1871
* Removes all events on user-space output buffer.
1872
* Unlike snd_seq_drain_output(), this function doesn't remove
1873
* events on output memory pool of sequencer.
1875
* \sa snd_seq_drop_output()
1878
snd_seq_drop_output_buffer (snd_seq_t * seq)
1880
dbg_printf ("snd_seq_drop_output_buffer(seq=%x)\n", seq);
1886
* \brief extract the first event in output buffer
1887
* \param seq sequencer handle
1888
* \param ev_res event pointer to be extracted
1889
* \return 0 on success otherwise a negative error code
1891
* Extracts the first event in output buffer.
1892
* If ev_res is NULL, just remove the event.
1894
* \sa snd_seq_event_output()
1897
snd_seq_extract_output (snd_seq_t * seq, snd_seq_event_t ** ev_res)
1899
dbg_printf ("snd_seq_extract_output(seq=%x)\n", seq);
1905
* \brief get size of #snd_seq_queue_status_t
1906
* \return size in bytes
1909
snd_seq_queue_status_sizeof ()
1911
return sizeof (snd_seq_queue_status_t);
1915
* \brief Return the size of output buffer
1916
* \param seq sequencer handle
1917
* \return the size of output buffer in bytes
1919
* Obtains the size of output buffer.
1920
* This buffer is used to store decoded byte-stream of output events
1921
* before transferring to sequencer.
1923
* \sa snd_seq_set_output_buffer_size()
1926
snd_seq_get_output_buffer_size (snd_seq_t * seq)
1928
dbg_printf ("snd_seq_get_output_buffer_size(seq=%x)\n", seq);
1934
* \brief Change the size of output buffer
1935
* \param seq sequencer handle
1936
* \param size the size of output buffer to be changed in bytes
1937
* \return 0 on success otherwise a negative error code
1939
* Changes the size of output buffer.
1941
* \sa snd_seq_get_output_buffer_size()
1944
snd_seq_set_output_buffer_size (snd_seq_t * seq, size_t size)
1946
dbg_printf ("snd_seq_set_output_buffer_size(seq=%x, size=%d)\n", seq, size);
1951
* \brief unsubscribe a connection between ports
1952
* \param seq sequencer handle
1953
* \param sub subscription information to disconnect
1954
* \return 0 on success otherwise a negative error code
1956
* Unsubscribes a connection between two ports,
1957
* described in sender and dest fields in sub argument.
1959
* \sa snd_seq_subscribe_port(), snd_seq_disconnect_from(), snd_seq_disconnect_to()
1962
snd_seq_unsubscribe_port (snd_seq_t * seq, snd_seq_port_subscribe_t * sub)
1964
dbg_printf ("snd_seq_unsubscribe_port(seq=%x, sub=%x)\n", seq, sub);
1970
* \brief Get the queue id of a queue_timer container
1971
* \param info queue_timer container
1974
* \sa snd_seq_get_queue_timer()
1977
snd_seq_queue_timer_get_queue (const snd_seq_queue_timer_t * info)
1979
dbg_printf ("snd_seq_queue_timer_get_queue(timer=%x)\n", info);
1985
* \brief obtain the queue timer information
1986
* \param seq sequencer handle
1987
* \param q queue id to query
1988
* \param timer pointer to store the timer information
1989
* \return 0 on success otherwise a negative error code
1991
* \sa snd_seq_set_queue_timer()
1994
snd_seq_get_queue_timer (snd_seq_t * seq, int q,
1995
snd_seq_queue_timer_t * timer)
1997
dbg_printf ("snd_seq_get_queue_timer(seq=%x, q=%d, timer=%x)\n",
2004
* \brief Set the timer id of a queue_timer container
2005
* \param info queue_timer container
2006
* \param id timer id pointer
2008
* \sa snd_seq_get_queue_timer()
2011
snd_seq_queue_timer_set_id (snd_seq_queue_timer_t * info,
2012
const snd_timer_id_t * id)
2014
dbg_printf ("snd_seq_queue_timer_set_id(timer=%x, id=%x)\n", info, id);
2018
* \brief get size of #snd_seq_queue_timer_t
2019
* \return size in bytes
2022
snd_seq_queue_timer_sizeof ()
2024
return sizeof (snd_seq_queue_timer_t);
2028
* \brief get size of #snd_seq_query_subscribe_t
2029
* \return size in bytes
2032
snd_seq_query_subscribe_sizeof ()
2034
return sizeof (snd_seq_query_subscribe_t);
2038
* \brief allocate an empty #snd_seq_query_subscribe_t using standard malloc
2039
* \param ptr returned pointer
2040
* \return 0 on success otherwise negative error code
2043
snd_seq_query_subscribe_malloc (snd_seq_query_subscribe_t ** ptr)
2045
*ptr = calloc (1, sizeof (snd_seq_query_subscribe_t));
2047
dbg_printf ("snd_seq_query_subscribe_malloc()=%x\n", *ptr);
2054
* \brief frees a previously allocated #snd_seq_query_subscribe_t
2055
* \param pointer to object to free
2058
snd_seq_query_subscribe_free (snd_seq_query_subscribe_t * obj)
2060
dbg_printf ("snd_seq_query_subscribe_free(obj=%x)\n", obj);
2065
* \brief Get the address of subscriber of a query_subscribe container
2066
* \param info query_subscribe container
2067
* \return subscriber's address pointer
2069
* \sa snd_seq_query_port_subscribers()
2071
const snd_seq_addr_t *
2072
snd_seq_query_subscribe_get_addr (const snd_seq_query_subscribe_t * info)
2074
dbg_printf ("snd_seq_query_subscribe_get_addr(info=%x)\n", info);
2076
return NULL; // TODO
2080
* \brief Get the index of subscriber of a query_subscribe container
2081
* \param info query_subscribe container
2082
* \return subscriber's index
2084
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_index()
2087
snd_seq_query_subscribe_get_index (const snd_seq_query_subscribe_t * info)
2089
dbg_printf ("snd_seq_query_subscribe_get_index(info=%x)\n", info);
2095
* \brief Set the subscriber's index to be queried
2096
* \param info query_subscribe container
2097
* \param index index to be queried
2099
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_index()
2102
snd_seq_query_subscribe_set_index (snd_seq_query_subscribe_t * info,
2105
dbg_printf ("snd_seq_query_subscribe_t(info=%x, index=%d)\n", info, index);
2111
* \brief Get the client/port address of a query_subscribe container
2112
* \param info query_subscribe container
2113
* \return client/port address pointer
2115
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_root()
2117
const snd_seq_addr_t *
2118
snd_seq_query_subscribe_get_root (const snd_seq_query_subscribe_t * info)
2120
dbg_printf ("snd_seq_query_subscribe_get_root(info=%x)\n", info);
2122
return NULL; // TODO
2126
* \brief Set the client/port address of a query_subscribe container
2127
* \param info query_subscribe container
2128
* \param addr client/port address pointer
2130
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_root()
2133
snd_seq_query_subscribe_set_root (snd_seq_query_subscribe_t * info,
2134
const snd_seq_addr_t * addr)
2136
dbg_printf ("snd_seq_query_subscribe_set_root(info=%d, addr=%x)\n",
2141
* \brief Get the query type of a query_subscribe container
2142
* \param info query_subscribe container
2143
* \return query type
2145
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_type()
2147
snd_seq_query_subs_type_t
2148
snd_seq_query_subscribe_get_type (const snd_seq_query_subscribe_t * info)
2150
dbg_printf ("snd_seq_query_subscribe_get_type(info=%x)\n", info);
2156
* \brief Set the query type of a query_subscribe container
2157
* \param info query_subscribe container
2158
* \param type query type
2160
* \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_type()
2163
snd_seq_query_subscribe_set_type (snd_seq_query_subscribe_t * info,
2164
snd_seq_query_subs_type_t type)
2166
dbg_printf ("snd_seq_query_subscribe_set_type(info=%x, type=%x)\n",
2173
* \brief obtain subscription information
2174
* \param seq sequencer handle
2175
* \param sub pointer to return the subscription information
2176
* \return 0 on success otherwise a negative error code
2178
* \sa snd_seq_subscribe_port(), snd_seq_query_port_subscribers()
2181
snd_seq_get_port_subscription (snd_seq_t * seq,
2182
snd_seq_port_subscribe_t * sub)
2184
dbg_printf ("snd_seq_get_port_subscription(seq=%x, sub=%x)\n", seq, sub);
2190
* \brief query port subscriber list
2191
* \param seq sequencer handle
2192
* \param subs subscription to query
2193
* \return 0 on success otherwise a negative error code
2195
* Queries the subscribers accessing to a port.
2196
* The query information is specified in subs argument.
2198
* At least, the client id, the port id, the index number and
2199
* the query type must be set to perform a proper query.
2200
* As the query type, #SND_SEQ_QUERY_SUBS_READ or #SND_SEQ_QUERY_SUBS_WRITE
2201
* can be specified to check whether the readers or the writers to the port.
2202
* To query the first subscription, set 0 to the index number. To list up
2203
* all the subscriptions, call this function with the index numbers from 0
2204
* until this returns a negative value.
2206
* \sa snd_seq_get_port_subscription()
2209
snd_seq_query_port_subscribers (snd_seq_t * seq, snd_seq_query_subscribe_t *
2212
dbg_printf ("snd_seq_query_port_subscribers(seq=%x, subs=%x)\n", seq, subs);
2218
* \brief Get the real time of a queue_status container
2219
* \param info queue_status container
2220
* \param time real time
2222
* \sa snd_seq_get_queue_status()
2224
const snd_seq_real_time_t *
2225
snd_seq_queue_status_get_real_time (const snd_seq_queue_status_t * info)
2227
dbg_printf ("snd_seq_queue_status_get_real_time(info=%x)\n", info);
2229
return NULL; // TODO