~ubuntu-branches/ubuntu/oneiric/oss4/oneiric-proposed

« back to all changes in this revision

Viewing changes to .pc/libsalsa_fixes.patch/lib/libsalsa/seq.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefano Rivera
  • Date: 2011-06-16 20:37:48 UTC
  • mfrom: (5.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110616203748-jbrxik6ql33z54co
Tags: 4.2-build2004-1ubuntu1
* Merge from Debian unstable.
  - Supports our current kernel (LP: #746048)
  Remaining changes:
  - debian/oss4-dkms.dkms.in: s/source/build/ in Kernel headers paths.
* ld-as-needed.patch: Re-order CC arguments to enable building with ld
  --as-needed (LP: #770972)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2004 by Hannu Savolainen < hannu@opensound.com>
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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
 
16
 *
 
17
 */
 
18
#include <stdio.h>
 
19
#include "local.h"
 
20
 
 
21
static int nports = 0;
 
22
 
 
23
typedef struct _snd_seq_port_subscribe
 
24
{
 
25
  int dummy;
 
26
} snd_seq_port_subscribe_t;
 
27
 
 
28
typedef struct _snd_seq_queue_tempo
 
29
{
 
30
  int dummy;
 
31
} snd_seq_queue_tempo_t;
 
32
 
 
33
typedef struct _snd_seq_system_info
 
34
{
 
35
  int dummy;
 
36
} snd_seq_system_info_t;
 
37
 
 
38
struct _snd_seq_remove_events
 
39
{
 
40
  int dummy;
 
41
};
 
42
 
 
43
struct _snd_seq_query_subscribe
 
44
{
 
45
  int dummy;
 
46
};
 
47
 
 
48
/**
 
49
 * \brief Open the ALSA sequencer
 
50
 *
 
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
 
57
 * three values:
 
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
 
63
 * open() call.
 
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
 
68
 *
 
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.
 
73
 *
 
74
 * \sa snd_seq_open_lconf(), snd_seq_close(), snd_seq_type(), snd_seq_name(),
 
75
 *     snd_seq_nonblock(), snd_seq_client_id()
 
76
 */
 
77
int
 
78
snd_seq_open (snd_seq_t ** seqp, const char *name, int streams, int mode)
 
79
{
 
80
  snd_seq_t *seq;
 
81
  int err, oss_mode;
 
82
  static int instance = 0;
 
83
 
 
84
  char *fname = "/dev/midi", *envname = NULL, tmp[128];
 
85
 
 
86
  ALIB_INIT ();
 
87
 
 
88
  dbg_printf ("snd_seq_open(name='%s', streams=%d, mode=%x)\n", name, streams,
 
89
              mode);
 
90
 
 
91
  if (!alib_appcheck ())
 
92
    return -ENODEV;
 
93
 
 
94
  instance++;
 
95
 
 
96
  sprintf (tmp, "%s_mididev%d", alib_appname, instance);
 
97
 
 
98
  if ((envname = getenv (tmp)) != NULL)
 
99
    {
 
100
      fname = envname;
 
101
    }
 
102
#if 0
 
103
  if (streams != 1)
 
104
    {
 
105
      fprintf (stderr, "salsa: snd_seq_open doesn't support streams=%d\n",
 
106
               streams);
 
107
      return -EIO;
 
108
    }
 
109
#endif
 
110
 
 
111
  if ((seq = malloc (sizeof (*seq))) == NULL)
 
112
    return -ENOMEM;
 
113
 
 
114
  dbg_printf ("Created sequencer seq=%x\n", seq);
 
115
 
 
116
  memset (seq, 0, sizeof (*seq));
 
117
 
 
118
  switch (streams)
 
119
    {
 
120
    case SND_SEQ_OPEN_INPUT:
 
121
      oss_mode = O_RDONLY;
 
122
      dbg_printf ("Open SND_SEQ_OPEN_INPUT\n");
 
123
      break;
 
124
    case SND_SEQ_OPEN_OUTPUT:
 
125
      oss_mode = O_WRONLY;
 
126
      dbg_printf ("Open SND_SEQ_OPEN_OUTPUT\n");
 
127
      break;
 
128
    case SND_SEQ_OPEN_DUPLEX:
 
129
      dbg_printf ("SND_SEQ_OPEN_DUPLEX\n");
 
130
      oss_mode = O_RDWR;
 
131
      break;
 
132
 
 
133
    default:
 
134
      fprintf (stderr, "snd_seq_open: Unknown stream %x\n", streams);
 
135
      return -ENODEV;
 
136
    }
 
137
 
 
138
  if ((seq->fd = open (fname, oss_mode, 0)) == -1)
 
139
    {
 
140
      err = errno;
 
141
      perror (fname);
 
142
 
 
143
      if (envname == NULL)
 
144
        {
 
145
          fprintf (stderr,
 
146
                   "You can select another filename using environment variable %s_mididev%d\n",
 
147
                   alib_appname, instance);
 
148
        }
 
149
      return -err;
 
150
    }
 
151
 
 
152
  seq->streams = streams;
 
153
  seq->oss_mode = oss_mode;
 
154
 
 
155
  if (streams == SND_SEQ_OPEN_INPUT || streams == SND_SEQ_OPEN_DUPLEX)
 
156
    {
 
157
      seq->parser = midiparser_create (midiparser_callback, seq);
 
158
      if (seq->parser == NULL)
 
159
        {
 
160
          fprintf (stderr, "libsalsa: Can't create MIDI parser\n");
 
161
          return -ENODEV;
 
162
        }
 
163
    }
 
164
 
 
165
  *seqp = seq;
 
166
  return 0;
 
167
}
 
168
 
 
169
/**
 
170
 * \brief Close the sequencer
 
171
 * \param handle Handle returned from #snd_seq_open()
 
172
 * \return 0 on success otherwise a negative error code
 
173
 *
 
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.
 
179
 *
 
180
 * \sa snd_seq_close()
 
181
 */
 
182
int
 
183
snd_seq_close (snd_seq_t * seq)
 
184
{
 
185
  dbg_printf ("snd_seq_close(seq=%x)\n", seq);
 
186
 
 
187
  close (seq->fd);
 
188
  free (seq);
 
189
}
 
190
 
 
191
/**
 
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
 
196
 *
 
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.
 
201
 *
 
202
 * \sa snd_seq_open()
 
203
 */
 
204
int
 
205
snd_seq_nonblock (snd_seq_t * seq, int nonblock)
 
206
{
 
207
  dbg_printf ("snd_seq_nonblock(seq=%x, nonblock=%d)\n", seq, nonblock);
 
208
 
 
209
  seq->nonblock = nonblock;
 
210
  return 0;
 
211
}
 
212
 
 
213
/**
 
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
 
218
 *
 
219
 * Creates a sequencer port on the current client.
 
220
 * The attributes of created port is specified in \a info argument.
 
221
 *
 
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.
 
225
 *
 
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
 
237
 *
 
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)
 
249
 *
 
250
 * A port may contain specific midi channels, midi voices and synth voices.
 
251
 * These values could be zero as default.
 
252
 *
 
253
 * \sa snd_seq_delete_port(), snd_seq_get_port_info(),
 
254
 *     snd_seq_create_simple_port()
 
255
 */
 
256
int
 
257
snd_seq_create_port (snd_seq_t * seq, snd_seq_port_info_t * port)
 
258
{
 
259
  dbg_printf ("snd_seq_create_port(seq=%x, port=%x)\n", seq, port);
 
260
 
 
261
  port->port = nports++;
 
262
  return 0;
 
263
}
 
264
 
 
265
/**
 
266
 * \brief Get the client id
 
267
 * \param seq sequencer handle
 
268
 * \return the client id
 
269
 *
 
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.
 
274
 *
 
275
 * \sa snd_seq_open()
 
276
 */
 
277
int
 
278
snd_seq_client_id (snd_seq_t * seq)
 
279
{
 
280
  static int client_id = 128;
 
281
 
 
282
  dbg_printf ("snd_seq_client_id(seq=%x)=%d\n", seq, client_id);
 
283
 
 
284
  return client_id++;
 
285
}
 
286
 
 
287
/**
 
288
 * \brief Get client id of a client_info container
 
289
 * \param info client_info container
 
290
 * \return client id
 
291
 *
 
292
 * \sa snd_seq_get_client_info(), snd_seq_client_info_set_client(), snd_seq_client_id()
 
293
 */
 
294
int
 
295
snd_seq_client_info_get_client (const snd_seq_client_info_t * info)
 
296
{
 
297
  dbg_printf ("snd_seq_client_info_get_client()\n");
 
298
 
 
299
  return 0;
 
300
}
 
301
 
 
302
/**
 
303
 * \brief Get client type of a client_info container
 
304
 * \param info client_info container
 
305
 * \return client type
 
306
 *
 
307
 * The client type is either #SEQ_CLIENT_TYPE_KERNEL or #SEQ_CLIENT_TYPE_USER
 
308
 * for kernel or user client respectively.
 
309
 *
 
310
 * \sa snd_seq_get_client_info()
 
311
 */
 
312
snd_seq_client_type_t
 
313
snd_seq_client_info_get_type (const snd_seq_client_info_t * info)
 
314
{
 
315
  dbg_printf ("snd_seq_client_info_get_type(infp=%x)\n", info);
 
316
 
 
317
  return SND_SEQ_KERNEL_CLIENT; // TODO
 
318
}
 
319
 
 
320
/**
 
321
 * \brief Set the client id of a client_info container
 
322
 * \param info client_info container
 
323
 * \param client client id
 
324
 *
 
325
 * \sa snd_seq_get_client_info(), snd_seq_client_info_get_client()
 
326
 */
 
327
void
 
328
snd_seq_client_info_set_client (snd_seq_client_info_t * info, int client)
 
329
{
 
330
  dbg_printf ("snd_seq_client_info_set_client(%x, %d)\n", info, client);
 
331
 
 
332
  info->client = client;
 
333
}
 
334
 
 
335
/**
 
336
 * \brief get size of #snd_seq_client_info_t
 
337
 * \return size in bytes
 
338
 */
 
339
size_t
 
340
snd_seq_client_info_sizeof ()
 
341
{
 
342
  dbg_printf ("snd_seq_client_info_sizeof()\n");
 
343
 
 
344
  return sizeof (snd_seq_client_info_t);
 
345
}
 
346
 
 
347
/**
 
348
 * \brief retrieve an event from sequencer
 
349
 * \param seq sequencer handle
 
350
 * \param ev event pointer to be stored
 
351
 * \return
 
352
 *
 
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.
 
355
 *
 
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.
 
360
 *
 
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
 
366
 * lost.
 
367
 * Once this error is returned, the input FIFO is cleared automatically.
 
368
 *
 
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.
 
373
 *
 
374
 * \sa snd_seq_event_input_pending(), snd_seq_drop_input()
 
375
 */
 
376
int
 
377
snd_seq_event_input (snd_seq_t * seq, snd_seq_event_t ** evp)
 
378
{
 
379
  static snd_seq_event_t *ev;
 
380
  unsigned char buf[256];
 
381
  int i, l;
 
382
 
 
383
  dbg_printf2 ("snd_seq_event_input(seq=%x)\n", seq);
 
384
 
 
385
  while (1)
 
386
    {
 
387
 
 
388
      if (seq->nextevent < seq->nevents)
 
389
        {
 
390
          *evp = &seq->events[seq->nextevent++];
 
391
 
 
392
          return (seq->nevents - seq->nextevent) * sizeof (snd_seq_event_t);
 
393
        }
 
394
 
 
395
      seq->nextevent = seq->nevents = 0;
 
396
      memset (seq->events, 0, sizeof (seq->events));
 
397
 
 
398
      // TODO Handling of nonblocking mode
 
399
      if ((l = read (seq->fd, buf, sizeof (buf))) == -1)
 
400
        return -errno;
 
401
 
 
402
      midiparser_input_buf (seq->parser, buf, l);
 
403
 
 
404
    }
 
405
 
 
406
}
 
407
 
 
408
/**
 
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
 
413
 *
 
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
 
417
 * actually sent.
 
418
 *
 
419
 * \sa snd_seq_event_output()
 
420
 */
 
421
int
 
422
snd_seq_event_output_direct (snd_seq_t * seq, snd_seq_event_t * ev)
 
423
{
 
424
  int err;
 
425
 
 
426
  dbg_printf3 ("snd_seq_event_output_direct()\n");
 
427
 
 
428
  if ((err = convert_event (seq, ev)) < 0)
 
429
    return err;
 
430
  if ((err = snd_seq_drain_output (seq)) < 0)
 
431
    return err;
 
432
 
 
433
  return 0;
 
434
}
 
435
 
 
436
/**
 
437
 * \brief (DEPRECATED) free an event
 
438
 *
 
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.
 
443
 */
 
444
int
 
445
snd_seq_free_event (snd_seq_event_t * ev)
 
446
{
 
447
  return 0;
 
448
}
 
449
 
 
450
/**
 
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
 
455
 *
 
456
 * Obtains the information of the current client stored on info.
 
457
 * client and type fields are ignored.
 
458
 *
 
459
 * \sa snd_seq_get_any_client_info(), snd_seq_set_client_info(),
 
460
 *     snd_seq_query_next_client()
 
461
 */
 
462
int
 
463
snd_seq_get_client_info (snd_seq_t * seq, snd_seq_client_info_t * info)
 
464
{
 
465
  dbg_printf ("snd_seq_get_client_info(seq=%x, info=%x)\n", seq, info);
 
466
 
 
467
  return 0;
 
468
}
 
469
 
 
470
/**
 
471
 * \brief query the next matching port
 
472
 * \param seq sequencer handle
 
473
 * \param info query pattern and result
 
474
                                                                                
 
475
 * Queries the next matching port on the client specified in
 
476
 * \a info argument.
 
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.
 
480
 *
 
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.
 
484
 *
 
485
 * \sa snd_seq_get_port_info()
 
486
 */
 
487
int
 
488
snd_seq_query_next_port (snd_seq_t * seq, snd_seq_port_info_t * info)
 
489
{
 
490
  dbg_printf ("snd_seq_query_next_port()\n");
 
491
 
 
492
  return -EINVAL;
 
493
}
 
494
 
 
495
/**
 
496
 * \brief Set the name of a client_info container
 
497
 * \param info client_info container
 
498
 * \param name name string
 
499
 *
 
500
 * \sa snd_seq_get_client_info(), snd_seq_client_info_get_name(),
 
501
 *     snd_seq_set_client_name()
 
502
 */
 
503
void
 
504
snd_seq_client_info_set_name (snd_seq_client_info_t * info, const char *name)
 
505
{
 
506
  dbg_printf ("snd_seq_client_info_set_name(%s)\n", name);
 
507
 
 
508
  strncpy (info->name, name, sizeof (info->name) - 1);
 
509
  info->name[sizeof (info->name) - 1] = 0;
 
510
}
 
511
 
 
512
/**
 
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
 
517
 *
 
518
 * Subscribes a connection between two ports.
 
519
 * The subscription information is stored in sub argument.
 
520
 *
 
521
 * \sa snd_seq_get_port_subscription(), snd_seq_unsubscribe_port(),
 
522
 *     snd_seq_connect_from(), snd_seq_connect_to()
 
523
 */
 
524
int
 
525
snd_seq_subscribe_port (snd_seq_t * seq, snd_seq_port_subscribe_t * sub)
 
526
{
 
527
  dbg_printf ("snd_seq_subscribe_port()\n");
 
528
 
 
529
  return -EINVAL;
 
530
}
 
531
 
 
532
/**
 
533
 * \brief get size of #snd_seq_port_subscribe_t
 
534
 * \return size in bytes
 
535
 */
 
536
size_t
 
537
snd_seq_port_subscribe_sizeof ()
 
538
{
 
539
  return sizeof (snd_seq_port_subscribe_t);
 
540
}
 
541
 
 
542
/**
 
543
 * \brief Set sender address of a port_subscribe container
 
544
 * \param info port_subscribe container
 
545
 * \param addr sender address
 
546
 *
 
547
 * \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_sender()
 
548
 */
 
549
void
 
550
snd_seq_port_subscribe_set_sender (snd_seq_port_subscribe_t * info,
 
551
                                   const snd_seq_addr_t * addr)
 
552
{
 
553
  dbg_printf ("snd_seq_port_subscribe_set_sender()\n");
 
554
}
 
555
 
 
556
/**
 
557
 * \brief Set destination address of a port_subscribe container
 
558
 * \param info port_subscribe container
 
559
 * \param addr destination address
 
560
 *
 
561
 * \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_dest()
 
562
 */
 
563
void
 
564
snd_seq_port_subscribe_set_dest (snd_seq_port_subscribe_t * info,
 
565
                                 const snd_seq_addr_t * addr)
 
566
{
 
567
  dbg_printf ("snd_seq_port_subscribe_set_dest()\n");
 
568
}
 
569
 
 
570
/**
 
571
 * \brief Set the queue id of a port_subscribe container
 
572
 * \param info port_subscribe container
 
573
 * \param q queue id
 
574
 *
 
575
 * \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_queue()
 
576
 */
 
577
void
 
578
snd_seq_port_subscribe_set_queue (snd_seq_port_subscribe_t * info, int q)
 
579
{
 
580
  dbg_printf ("snd_seq_port_subscribe_set_queue()\n");
 
581
}
 
582
 
 
583
/**
 
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
 
587
 *
 
588
 * \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_time_real()
 
589
 */
 
590
void
 
591
snd_seq_port_subscribe_set_time_real (snd_seq_port_subscribe_t * info,
 
592
                                      int val)
 
593
{
 
594
  dbg_printf ("snd_seq_port_subscribe_set_time_real()\n");
 
595
}
 
596
 
 
597
/**
 
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
 
601
 *
 
602
 * \sa snd_seq_subscribe_port(), snd_seq_port_subscribe_get_time_update()
 
603
 */
 
604
void
 
605
snd_seq_port_subscribe_set_time_update (snd_seq_port_subscribe_t * info, int
 
606
                                        val)
 
607
{
 
608
  dbg_printf ("snd_seq_port_subscribe_set_time_update()\n");
 
609
}
 
610
 
 
611
/*
 
612
 * Port
 
613
 */
 
614
 
 
615
/**
 
616
 * \brief get size of #snd_seq_port_info_t
 
617
 * \return size in bytes
 
618
 */
 
619
size_t
 
620
snd_seq_port_info_sizeof ()
 
621
{
 
622
  return sizeof (snd_seq_port_info_t);
 
623
}
 
624
 
 
625
/**
 
626
 * \brief Get the capability bits of a port_info container
 
627
 * \param info port_info container
 
628
 * \return capability bits
 
629
 *
 
630
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_capability()
 
631
 */
 
632
unsigned int
 
633
snd_seq_port_info_get_capability (const snd_seq_port_info_t * info)
 
634
{
 
635
  dbg_printf ("snd_seq_port_info_get_capability()\n");
 
636
 
 
637
  return info->capability;
 
638
}
 
639
 
 
640
/**
 
641
 * \brief Get client/port address of a port_info container
 
642
 * \param info port_info container
 
643
 * \return client/port address pointer
 
644
 *
 
645
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_addr()
 
646
 */
 
647
const snd_seq_addr_t *
 
648
snd_seq_port_info_get_addr (const snd_seq_port_info_t * info)
 
649
{
 
650
  dbg_printf ("snd_seq_port_info_get_addr(info=%x)\n", info);
 
651
 
 
652
  return NULL;                  // TODO
 
653
}
 
654
 
 
655
/**
 
656
 * \brief set the capability bits of a port_info container
 
657
 * \param info port_info container
 
658
 * \param capability capability bits
 
659
 *
 
660
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_capability()
 
661
 */
 
662
void
 
663
snd_seq_port_info_set_capability (snd_seq_port_info_t * info,
 
664
                                  unsigned int capability)
 
665
{
 
666
  dbg_printf ("snd_seq_port_info_set_capability()\n");
 
667
}
 
668
 
 
669
/**
 
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
 
673
 *
 
674
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_port_specified()
 
675
 */
 
676
void
 
677
snd_seq_port_info_set_port_specified (snd_seq_port_info_t * info, int val)
 
678
{
 
679
  dbg_printf ("snd_seq_port_info_set_port_specified()\n");
 
680
}
 
681
 
 
682
/**
 
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)
 
686
 *
 
687
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_midi_channels()
 
688
 */
 
689
int
 
690
snd_seq_port_info_get_midi_channels (const snd_seq_port_info_t * info)
 
691
{
 
692
  dbg_printf ("snd_seq_port_info_get_midi_channels(info=%x)=%d\n",
 
693
              info, info->midi_channels);
 
694
 
 
695
  return info->midi_channels;
 
696
}
 
697
 
 
698
/**
 
699
 * \brief set the midi channels of a port_info container
 
700
 * \param info port_info container
 
701
 * \param channels midi channels (default 0)
 
702
 *
 
703
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_midi_channels()
 
704
 */
 
705
void
 
706
snd_seq_port_info_set_midi_channels (snd_seq_port_info_t * info, int channels)
 
707
{
 
708
  dbg_printf ("snd_seq_port_info_set_midi_channels(info=%x, channels=%d)\n",
 
709
              info, channels);
 
710
  info->midi_channels = channels;
 
711
}
 
712
 
 
713
/**
 
714
 * \brief Get the queue id to update timestamps
 
715
 * \param info port_info container
 
716
 * \return the queue id to get the timestamps
 
717
 *
 
718
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamp_queue()
 
719
 */
 
720
int
 
721
snd_seq_port_info_get_timestamp_queue (const snd_seq_port_info_t * info)
 
722
{
 
723
  dbg_printf ("snd_seq_port_info_get_timestamp_queue(info=%x)\n", info);
 
724
 
 
725
  return 0;                     // TODO
 
726
}
 
727
 
 
728
/**
 
729
 * \brief Set the queue id for timestamping
 
730
 * \param info port_info container
 
731
 * \param queue the queue id to get timestamps
 
732
 *
 
733
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamp_queue()
 
734
 */
 
735
void
 
736
snd_seq_port_info_set_timestamp_queue (snd_seq_port_info_t * info, int queue)
 
737
{
 
738
  dbg_printf ("snd_seq_port_info_set_timestamp_queue(info=%x, queue=%d)\n",
 
739
              info, queue);
 
740
 
 
741
  // TODO
 
742
}
 
743
 
 
744
/**
 
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
 
748
 *
 
749
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamp_real()
 
750
 */
 
751
int
 
752
snd_seq_port_info_get_timestamp_real (const snd_seq_port_info_t * info)
 
753
{
 
754
  dbg_printf ("snd_seq_port_info_get_timestamp_real(info=%x)\n", info);
 
755
 
 
756
  return 0;                     // TODO
 
757
}
 
758
 
 
759
/**
 
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
 
763
 *
 
764
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamp_real()
 
765
 */
 
766
void
 
767
snd_seq_port_info_set_timestamp_real (snd_seq_port_info_t * info, int enable)
 
768
{
 
769
  dbg_printf ("snd_seq_port_info_set_timestamp_real(infp=%x, enable=%d)\n",
 
770
              info, enable);
 
771
}
 
772
 
 
773
/**
 
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
 
776
 *
 
777
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_timestamping()
 
778
 */
 
779
int
 
780
snd_seq_port_info_get_timestamping (const snd_seq_port_info_t * info)
 
781
{
 
782
  dbg_printf ("snd_seq_port_info_get_timestamping(info=%x)\n", info);
 
783
 
 
784
  return 0;                     // TODO
 
785
}
 
786
 
 
787
/**
 
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
 
791
 *
 
792
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_timestamping()
 
793
 */
 
794
void
 
795
snd_seq_port_info_set_timestamping (snd_seq_port_info_t * info, int enable)
 
796
{
 
797
  dbg_printf ("snd_seq_port_info_set_timestamping(info=%x, enable=%d)\n",
 
798
              info, enable);
 
799
 
 
800
  // TODO
 
801
}
 
802
 
 
803
/**
 
804
 * \brief Set the name of a port_info container
 
805
 * \param info port_info container
 
806
 * \param name name string
 
807
 *
 
808
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_name()
 
809
 */
 
810
void
 
811
snd_seq_port_info_set_name (snd_seq_port_info_t * info, const char *name)
 
812
{
 
813
  dbg_printf ("snd_seq_port_info_set_name()\n");
 
814
 
 
815
  strncpy (info->name, name, sizeof (info->name));
 
816
}
 
817
 
 
818
/**
 
819
 * \brief Get the name of a port_info container
 
820
 * \param info port_info container
 
821
 * \return name string
 
822
 *
 
823
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_name()
 
824
 */
 
825
const char *
 
826
snd_seq_port_info_get_name (const snd_seq_port_info_t * info)
 
827
{
 
828
  dbg_printf ("snd_seq_port_info_get_name()\n");
 
829
 
 
830
  return "Port Name";
 
831
}
 
832
 
 
833
/**
 
834
 * \brief Get port id of a port_info container
 
835
 * \param info port_info container
 
836
 * \return port id
 
837
 *
 
838
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_port()
 
839
 */
 
840
int
 
841
snd_seq_port_info_get_port (const snd_seq_port_info_t * info)
 
842
{
 
843
  dbg_printf ("snd_seq_port_info_get_port()\n");
 
844
 
 
845
  return -EIO;
 
846
}
 
847
 
 
848
/**
 
849
 * \brief Get the type bits of a port_info container
 
850
 * \param info port_info container
 
851
 * \return port type bits
 
852
 *
 
853
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_type()
 
854
 */
 
855
unsigned int
 
856
snd_seq_port_info_get_type (const snd_seq_port_info_t * info)
 
857
{
 
858
  dbg_printf ("snd_seq_port_info_get_type()\n");
 
859
 
 
860
  return info->type;
 
861
}
 
862
 
 
863
/**
 
864
 * \brief Set the client id of a port_info container
 
865
 * \param info port_info container
 
866
 * \param client client id
 
867
 *
 
868
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_client()
 
869
 */
 
870
void
 
871
snd_seq_port_info_set_client (snd_seq_port_info_t * info, int client)
 
872
{
 
873
  dbg_printf ("snd_seq_port_info_set_client()\n");
 
874
}
 
875
 
 
876
/**
 
877
 * \brief Set the port id of a port_info container
 
878
 * \param info port_info container
 
879
 * \param port port id
 
880
 *
 
881
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_port()
 
882
 */
 
883
void
 
884
snd_seq_port_info_set_port (snd_seq_port_info_t * info, int port)
 
885
{
 
886
  dbg_printf ("snd_seq_port_info_set_port()\n");
 
887
}
 
888
 
 
889
/**
 
890
 * \brief query the next matching client
 
891
 * \param seq sequencer handle
 
892
 * \param info query pattern and result
 
893
 *
 
894
 * Queries the next matching client with the given condition in
 
895
 * info argument.
 
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.
 
902
 *
 
903
 * \sa snd_seq_get_any_client_info()
 
904
 */
 
905
int
 
906
snd_seq_query_next_client (snd_seq_t * seq, snd_seq_client_info_t * info)
 
907
{
 
908
  dbg_printf ("snd_seq_query_next_client()\n");
 
909
 
 
910
  return -EIO;
 
911
}
 
912
 
 
913
/**
 
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
 
918
 *
 
919
 * Obtains the information of the current client stored on info.
 
920
 * client and type fields are ignored.
 
921
 *
 
922
 * \sa snd_seq_get_client_info()
 
923
 */
 
924
int
 
925
snd_seq_set_client_info (snd_seq_t * seq, snd_seq_client_info_t * info)
 
926
{
 
927
  dbg_printf ("snd_seq_set_client_info(seq=%x, info=%x)\n", seq, info);
 
928
 
 
929
  if (*info->name)
 
930
    {
 
931
      strcpy (seq->name, info->name);
 
932
      ioctl (seq->fd, SNDCTL_SETNAME, seq->name);
 
933
      ioctl (seq->fd, SNDCTL_SETSONG, seq->name);
 
934
    }
 
935
 
 
936
  return 0;
 
937
}
 
938
 
 
939
/**
 
940
 * \brief check events in input buffer
 
941
 * \return the byte size of remaining input events on input buffer.
 
942
 *
 
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.
 
951
 *
 
952
 * \sa snd_seq_event_input()
 
953
 */
 
954
int
 
955
snd_seq_event_input_pending (snd_seq_t * seq, int fetch_sequencer)
 
956
{
 
957
  dbg_printf ("snd_seq_event_input_pending()\n");
 
958
 
 
959
  return 0;
 
960
}
 
961
 
 
962
/**
 
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
 
969
 *
 
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.
 
974
 *
 
975
 * To check the returned poll-events, call #snd_seq_poll_descriptors_revents()
 
976
 * instead of reading the pollfd structs directly.
 
977
 *
 
978
 * \sa snd_seq_poll_descriptors_count(), snd_seq_poll_descriptors_revents()
 
979
 */
 
980
int
 
981
snd_seq_poll_descriptors (snd_seq_t * seq, struct pollfd *pfds,
 
982
                          unsigned int space, short events)
 
983
{
 
984
  dbg_printf ("snd_seq_poll_descriptors(seq=%x)\n", seq);
 
985
 
 
986
  pfds->fd = seq->fd;
 
987
  pfds->events = 0;
 
988
  pfds->revents = 0;
 
989
 
 
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;
 
994
 
 
995
  return 1;
 
996
}
 
997
 
 
998
 
 
999
/**
 
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.
 
1004
 *
 
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
 
1008
 *
 
1009
 * \sa snd_seq_poll_descriptors()
 
1010
 */
 
1011
int
 
1012
snd_seq_poll_descriptors_count (snd_seq_t * seq, short events)
 
1013
{
 
1014
  dbg_printf ("snd_seq_poll_descriptors_count(seq=%x, events=%x)\n",
 
1015
              seq, events);
 
1016
  return 1;
 
1017
}
 
1018
 
 
1019
/**
 
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
 
1024
 *
 
1025
 * \sa snd_seq_alloc_queue()
 
1026
 */
 
1027
int
 
1028
snd_seq_create_queue (snd_seq_t * seq, snd_seq_queue_info_t * info)
 
1029
{
 
1030
  dbg_printf ("snd_seq_create_queue()\n");
 
1031
 
 
1032
  return 0;
 
1033
}
 
1034
 
 
1035
/**
 
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
 
1041
 *
 
1042
 * Connect from the given receiver port in the current client
 
1043
 * to the given destination client:port.
 
1044
 *
 
1045
 * \sa snd_seq_subscribe_port(), snd_seq_disconnect_to()
 
1046
 */
 
1047
int
 
1048
snd_seq_connect_to (snd_seq_t * seq, int myport, int dest_client,
 
1049
                    int dest_port)
 
1050
{
 
1051
  dbg_printf ("snd_seq_connect_to(%d->%d/%d)\n", myport, dest_client,
 
1052
              dest_port);
 
1053
 
 
1054
  return 0;
 
1055
}
 
1056
 
 
1057
/**
 
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
 
1063
 *
 
1064
 * Connect from the given sender client:port to the given destination port in the
 
1065
 * current client.
 
1066
 *
 
1067
 * \sa snd_seq_subscribe_port(), snd_seq_disconnect_from()
 
1068
 */
 
1069
int
 
1070
snd_seq_connect_from (snd_seq_t * seq, int myport, int src_client,
 
1071
                      int src_port)
 
1072
{
 
1073
  dbg_printf
 
1074
    ("snd_seq_connect_from(seq=%x, myport=%d, src_client=%d, src_port=%d)\n",
 
1075
     seq, myport, src_client, src_port);
 
1076
 
 
1077
  return 0;
 
1078
}
 
1079
 
 
1080
/**
 
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
 
1087
 *
 
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.
 
1093
 *
 
1094
 * \sa snd_seq_alloc_queue()
 
1095
 */
 
1096
int
 
1097
snd_seq_control_queue (snd_seq_t * seq, int q, int type, int value,
 
1098
                       snd_seq_event_t * ev)
 
1099
{
 
1100
  dbg_printf ("snd_seq_control_queue()\n");
 
1101
 
 
1102
  return 0;
 
1103
}
 
1104
 
 
1105
/**
 
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.
 
1111
 *
 
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.
 
1117
 *
 
1118
 * \sa snd_seq_event_output(), snd_seq_sync_output_queue()
 
1119
 */
 
1120
int
 
1121
snd_seq_drain_output (snd_seq_t * seq)
 
1122
{
 
1123
  dbg_printf3 ("snd_seq_drain_output(seq=%x)\n", seq);
 
1124
 
 
1125
  return 0;
 
1126
}
 
1127
 
 
1128
 
 
1129
/**
 
1130
 * \brief remove all events on output buffer
 
1131
 * \param seq sequencer handle
 
1132
 *
 
1133
 * Removes all events on both user-space output buffer and
 
1134
 * output memory pool on kernel.
 
1135
 *
 
1136
 * \sa snd_seq_drain_output(), snd_seq_drop_output_buffer(), snd_seq_remove_events()
 
1137
 */
 
1138
int
 
1139
snd_seq_drop_output (snd_seq_t * seq)
 
1140
{
 
1141
  dbg_printf ("snd_seq_drop_output()\n");
 
1142
 
 
1143
  return 0;
 
1144
}
 
1145
 
 
1146
/**
 
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
 
1151
 *
 
1152
 * An event is once expanded on the output buffer.
 
1153
 * The output buffer will be drained automatically if it becomes full.
 
1154
 *
 
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.
 
1158
 *
 
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()
 
1163
 */
 
1164
int
 
1165
snd_seq_event_output (snd_seq_t * seq, snd_seq_event_t * ev)
 
1166
{
 
1167
  dbg_printf3 ("snd_seq_event_output(seq=%x, ev=%x)\n", seq, ev);
 
1168
 
 
1169
  return convert_event (seq, ev);
 
1170
}
 
1171
 
 
1172
/**
 
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
 
1177
 *
 
1178
 * \sa snd_seq_alloc_queue()
 
1179
 */
 
1180
int
 
1181
snd_seq_free_queue (snd_seq_t * seq, int q)
 
1182
{
 
1183
  dbg_printf ("snd_seq_free_queue()\n");
 
1184
 
 
1185
  return 0;
 
1186
}
 
1187
 
 
1188
/**
 
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
 
1194
 *
 
1195
 * Obtains the information of the client with a client id specified by
 
1196
 * info argument.
 
1197
 * The obtained information is written on info parameter.
 
1198
 *
 
1199
 * \sa snd_seq_get_client_info()
 
1200
 */
 
1201
int
 
1202
snd_seq_get_any_client_info (snd_seq_t * seq, int client,
 
1203
                             snd_seq_client_info_t * info)
 
1204
{
 
1205
  dbg_printf ("snd_seq_get_any_client_info()\n");
 
1206
 
 
1207
  strcpy (info->name, seq->name);
 
1208
 
 
1209
  return 0;
 
1210
}
 
1211
 
 
1212
/**
 
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
 
1219
 *
 
1220
 * \sa snd_seq_get_port_info()
 
1221
 */
 
1222
int
 
1223
snd_seq_get_any_port_info (snd_seq_t * seq, int client, int port,
 
1224
                           snd_seq_port_info_t * info)
 
1225
{
 
1226
  dbg_printf ("snd_seq_get_any_port_info()\n");
 
1227
 
 
1228
  return 0;
 
1229
}
 
1230
 
 
1231
/**
 
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
 
1235
 */
 
1236
int
 
1237
snd_seq_port_info_malloc (snd_seq_port_info_t ** ptr)
 
1238
{
 
1239
  snd_seq_port_info_t *p;
 
1240
 
 
1241
  dbg_printf ("snd_seq_port_info_malloc()\n");
 
1242
 
 
1243
  if ((p = malloc (sizeof (*p))) == NULL)
 
1244
    return -ENOMEM;
 
1245
 
 
1246
  *ptr = p;
 
1247
 
 
1248
  return 0;
 
1249
}
 
1250
 
 
1251
/**
 
1252
 * \brief frees a previously allocated #snd_seq_port_info_t
 
1253
 * \param pointer to object to free
 
1254
 */
 
1255
void
 
1256
snd_seq_port_info_free (snd_seq_port_info_t * obj)
 
1257
{
 
1258
  free (obj);
 
1259
}
 
1260
 
 
1261
/**
 
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
 
1265
 */
 
1266
int
 
1267
snd_seq_queue_tempo_malloc (snd_seq_queue_tempo_t ** ptr)
 
1268
{
 
1269
  assert (ptr);
 
1270
  *ptr = calloc (1, sizeof (snd_seq_queue_tempo_t));
 
1271
  dbg_printf ("snd_seq_queue_tempo_malloc()=%x\n", *ptr);
 
1272
  if (!*ptr)
 
1273
    return -ENOMEM;
 
1274
  return 0;
 
1275
}
 
1276
 
 
1277
/**
 
1278
 * \brief frees a previously allocated #snd_seq_queue_tempo_t
 
1279
 * \param pointer to object to free
 
1280
 */
 
1281
void
 
1282
snd_seq_queue_tempo_free (snd_seq_queue_tempo_t * obj)
 
1283
{
 
1284
  dbg_printf ("snd_seq_queue_tempo_free(%x)\n", obj);
 
1285
  free (obj);
 
1286
}
 
1287
 
 
1288
/**
 
1289
 * \brief Set the ppq of a queue_status container
 
1290
 * \param info queue_status container
 
1291
 * \param ppq ppq value
 
1292
 *
 
1293
 * \sa snd_seq_get_queue_tempo()
 
1294
 */
 
1295
void
 
1296
snd_seq_queue_tempo_set_ppq (snd_seq_queue_tempo_t * info, int ppq)
 
1297
{
 
1298
  dbg_printf ("snd_seq_queue_tempo_set_ppq(info=%x, %d)\n", info, ppq);
 
1299
}
 
1300
 
 
1301
/**
 
1302
 * \brief Set the tempo of a queue_status container
 
1303
 * \param info queue_status container
 
1304
 * \param tempo tempo value
 
1305
 *
 
1306
 * \sa snd_seq_get_queue_tempo()
 
1307
 */
 
1308
void
 
1309
snd_seq_queue_tempo_set_tempo (snd_seq_queue_tempo_t * info,
 
1310
                               unsigned int tempo)
 
1311
{
 
1312
  dbg_printf ("snd_seq_queue_tempo_set_tempo(info=%x, %d)\n", info, tempo);
 
1313
}
 
1314
 
 
1315
/**
 
1316
 * \brief get size of #snd_seq_queue_tempo_t
 
1317
 * \return size in bytes
 
1318
 */
 
1319
size_t
 
1320
snd_seq_queue_tempo_sizeof ()
 
1321
{
 
1322
  return sizeof (snd_seq_queue_tempo_t);
 
1323
}
 
1324
 
 
1325
/**
 
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
 
1331
 *
 
1332
 * \sa snd_seq_get_queue_timer()
 
1333
 */
 
1334
int
 
1335
snd_seq_set_queue_timer (snd_seq_t * seq, int q,
 
1336
                         snd_seq_queue_timer_t * timer)
 
1337
{
 
1338
  dbg_printf ("snd_seq_get_queue_timer(seq=%x, q=%d, timer=%X)\n", seq, q,
 
1339
              timer);
 
1340
  return -ENXIO;                // TODO
 
1341
}
 
1342
 
 
1343
 
 
1344
/**
 
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
 
1350
 *
 
1351
 * Opens a new connection to the RawMidi interface specified with
 
1352
 * an ASCII identifier and mode.
 
1353
 */
 
1354
int
 
1355
snd_timer_query_open (snd_timer_query_t ** timer, const char *name, int mode)
 
1356
{
 
1357
  dbg_printf ("snd_timer_query_open(name=%s, mode=%x)\n", name, mode);
 
1358
  return -ENXIO;                // TODO
 
1359
}
 
1360
 
 
1361
/**
 
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
 
1367
 *
 
1368
 * \sa snd_seq_set_queue_tempo()
 
1369
 */
 
1370
int
 
1371
snd_seq_get_queue_tempo (snd_seq_t * seq, int q,
 
1372
                         snd_seq_queue_tempo_t * tempo)
 
1373
{
 
1374
  dbg_printf ("snd_seq_get_queue_tempo(seq=%x, q=%d, tempo=%x)\n", seq, q,
 
1375
              tempo);
 
1376
 
 
1377
  return 0;
 
1378
}
 
1379
 
 
1380
/**
 
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
 
1384
 */
 
1385
int
 
1386
snd_seq_client_info_malloc (snd_seq_client_info_t ** ptr)
 
1387
{
 
1388
  dbg_printf ("snd_seq_client_info_malloc()\n");
 
1389
 
 
1390
  *ptr = malloc (sizeof (snd_seq_client_info_t));
 
1391
  if (!*ptr)
 
1392
    return -ENOMEM;
 
1393
  return 0;
 
1394
}
 
1395
 
 
1396
/**
 
1397
 * \brief frees a previously allocated #snd_seq_client_info_t
 
1398
 * \param pointer to object to free
 
1399
 */
 
1400
void
 
1401
snd_seq_client_info_free (snd_seq_client_info_t * obj)
 
1402
{
 
1403
  dbg_printf ("snd_seq_client_info_free()\n");
 
1404
 
 
1405
  free (obj);
 
1406
}
 
1407
 
 
1408
/**
 
1409
 * \brief Get the name of a client_info container
 
1410
 * \param info client_info container
 
1411
 * \return name string
 
1412
 *
 
1413
 * \sa snd_seq_get_client_info(), snd_seq_client_info_set_name()
 
1414
 */
 
1415
const char *
 
1416
snd_seq_client_info_get_name (snd_seq_client_info_t * info)
 
1417
{
 
1418
  dbg_printf ("snd_seq_client_info_get_name()\n");
 
1419
  return "OSS seq client";
 
1420
}
 
1421
 
 
1422
/**
 
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
 
1426
 *
 
1427
 * \sa snd_seq_get_client_info()
 
1428
 */
 
1429
int
 
1430
snd_seq_client_info_get_num_ports (const snd_seq_client_info_t * info)
 
1431
{
 
1432
  dbg_printf ("snd_seq_client_info_get_num_ports()\n");
 
1433
 
 
1434
  return 1;
 
1435
}
 
1436
 
 
1437
/**
 
1438
 * \brief Get size of #snd_seq_system_info_t
 
1439
 * \return size in bytes
 
1440
 */
 
1441
size_t
 
1442
snd_seq_system_info_sizeof ()
 
1443
{
 
1444
  return sizeof (snd_seq_system_info_t);
 
1445
}
 
1446
 
 
1447
 
 
1448
/**
 
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
 
1452
 */
 
1453
int
 
1454
snd_seq_system_info_malloc (snd_seq_system_info_t ** ptr)
 
1455
{
 
1456
  dbg_printf ("snd_seq_system_info_malloc()\n");
 
1457
 
 
1458
  *ptr = malloc (sizeof (snd_seq_system_info_t));
 
1459
  if (*ptr == NULL)
 
1460
    return -ENOMEM;
 
1461
  return 0;
 
1462
}
 
1463
 
 
1464
/**
 
1465
 * \brief Frees a previously allocated #snd_seq_system_info_t
 
1466
 * \param pointer to object to free
 
1467
 */
 
1468
void
 
1469
snd_seq_system_info_free (snd_seq_system_info_t * obj)
 
1470
{
 
1471
  free (obj);
 
1472
}
 
1473
 
 
1474
/**
 
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
 
1479
 *
 
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.
 
1483
 */
 
1484
int
 
1485
snd_seq_system_info (snd_seq_t * seq, snd_seq_system_info_t * info)
 
1486
{
 
1487
  dbg_printf ("snd_seq_system_info()\n");
 
1488
 
 
1489
  return 0;
 
1490
}
 
1491
 
 
1492
/**
 
1493
 * \brief Get maximum number of clients
 
1494
 * \param info #snd_seq_system_info_t container
 
1495
 * \return maximum number of clients
 
1496
 *
 
1497
 * \sa snd_seq_system_info()
 
1498
 */
 
1499
int
 
1500
snd_seq_system_info_get_clients (const snd_seq_system_info_t * info)
 
1501
{
 
1502
  dbg_printf ("snd_seq_system_info_get_clients()\n");
 
1503
 
 
1504
  return 4;
 
1505
}
 
1506
 
 
1507
/**
 
1508
 * \brief Get maximum number of queues
 
1509
 * \param info #snd_seq_system_info_t container
 
1510
 * \return maximum number of queues
 
1511
 *
 
1512
 * \sa snd_seq_system_info()
 
1513
 */
 
1514
int
 
1515
snd_seq_system_info_get_queues (const snd_seq_system_info_t * info)
 
1516
{
 
1517
  dbg_printf ("snd_seq_system_info_get_queues(info=%x)\n", info);
 
1518
 
 
1519
  return 1;                     // TODO
 
1520
}
 
1521
 
 
1522
/**
 
1523
 * \brief Get maximum number of ports
 
1524
 * \param info #snd_seq_system_info_t container
 
1525
 * \return maximum number of ports
 
1526
 *
 
1527
 * \sa snd_seq_system_info()
 
1528
 */
 
1529
int
 
1530
snd_seq_system_info_get_ports (const snd_seq_system_info_t * info)
 
1531
{
 
1532
  dbg_printf ("snd_seq_system_info_get_ports()\n");
 
1533
 
 
1534
  return 4;
 
1535
}
 
1536
 
 
1537
/**
 
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
 
1542
 *
 
1543
 * \sa snd_seq_alloc_queue()
 
1544
 */
 
1545
int
 
1546
snd_seq_alloc_named_queue (snd_seq_t * seq, const char *name)
 
1547
{
 
1548
  dbg_printf ("snd_seq_alloc_named_queue(seq=%x, name=%s)\n", seq, name);
 
1549
 
 
1550
  return 0;
 
1551
}
 
1552
 
 
1553
 
 
1554
/**
 
1555
 * \brief Get client id of a port_info container
 
1556
 * \param info port_info container
 
1557
 * \return client id
 
1558
 *
 
1559
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_client()
 
1560
 */
 
1561
int
 
1562
snd_seq_port_info_get_client (const snd_seq_port_info_t * info)
 
1563
{
 
1564
  dbg_printf ("snd_seq_port_info_get_client()\n");
 
1565
 
 
1566
  return 0;
 
1567
}
 
1568
 
 
1569
/**
 
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
 
1573
 *
 
1574
 * \sa snd_seq_get_port_info(), snd_seq_port_info_set_port_specified()
 
1575
 */
 
1576
int
 
1577
snd_seq_port_info_get_port_specified (const snd_seq_port_info_t * info)
 
1578
{
 
1579
  dbg_printf ("snd_seq_port_info_get_port_specified()\n");
 
1580
 
 
1581
  return 0;
 
1582
}
 
1583
 
 
1584
/**
 
1585
 * \brief Get the type bits of a port_info container
 
1586
 * \param info port_info container
 
1587
 * \return port type bits
 
1588
 *
 
1589
 * \sa snd_seq_get_port_info(), snd_seq_port_info_get_type()
 
1590
 */
 
1591
void
 
1592
snd_seq_port_info_set_type (snd_seq_port_info_t * info, unsigned int type)
 
1593
{
 
1594
  dbg_printf ("snd_seq_port_info_set_type(%u)\n", type);
 
1595
}
 
1596
 
 
1597
 
 
1598
/**
 
1599
 * \brief Get the ppq of a queue_status container
 
1600
 * \param info queue_status container
 
1601
 * \return ppq value
 
1602
 *
 
1603
 * \sa snd_seq_get_queue_tempo()
 
1604
 */
 
1605
int
 
1606
snd_seq_queue_tempo_get_ppq (const snd_seq_queue_tempo_t * info)
 
1607
{
 
1608
  dbg_printf ("snd_seq_queue_tempo_get_ppq()\n");
 
1609
 
 
1610
  return 0;
 
1611
}
 
1612
 
 
1613
 
 
1614
/**
 
1615
 * \brief Get the tempo of a queue_status container
 
1616
 * \param info queue_status container
 
1617
 * \return tempo value
 
1618
 *
 
1619
 * \sa snd_seq_get_queue_tempo()
 
1620
 */
 
1621
unsigned int
 
1622
snd_seq_queue_tempo_get_tempo (const snd_seq_queue_tempo_t * info)
 
1623
{
 
1624
  dbg_printf ("snd_seq_queue_tempo_get_tempo()\n");
 
1625
 
 
1626
  return 0;
 
1627
}
 
1628
 
 
1629
/**
 
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
 
1635
 *
 
1636
 * \sa snd_seq_get_queue_tempo()
 
1637
 */
 
1638
int
 
1639
snd_seq_set_queue_tempo (snd_seq_t * seq, int q,
 
1640
                         snd_seq_queue_tempo_t * tempo)
 
1641
{
 
1642
  dbg_printf ("snd_seq_set_queue_tempo(seq=%x, q=%d, tempo=%x)\n", seq, q,
 
1643
              tempo);
 
1644
 
 
1645
  return 0;
 
1646
}
 
1647
 
 
1648
/**
 
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
 
1652
 *
 
1653
 * \sa snd_seq_alloc_named_queue(), snd_seq_create_queue(), snd_seq_free_queue(),
 
1654
 *     snd_seq_get_queue_info()
 
1655
 */
 
1656
int
 
1657
snd_seq_alloc_queue (snd_seq_t * seq)
 
1658
{
 
1659
  static int queue_num = 0;
 
1660
  dbg_printf ("snd_seq_alloc_queue(seq=%x)=%d\n", seq, queue_num);
 
1661
 
 
1662
  return queue_num++;
 
1663
}
 
1664
 
 
1665
#define FIXED_EV(x)     (_SND_SEQ_TYPE(SND_SEQ_EVFLG_FIXED) | _SND_SEQ_TYPE(x))
 
1666
 
 
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]
 
1672
    =
 
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]
 
1681
    =
 
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),
 
1706
};
 
1707
 
 
1708
/**
 
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
 
1714
 *
 
1715
 * Obtains the running state of the specified queue q.
 
1716
 */
 
1717
int
 
1718
snd_seq_get_queue_status (snd_seq_t * seq, int q,
 
1719
                          snd_seq_queue_status_t * status)
 
1720
{
 
1721
  dbg_printf ("snd_seq_get_queue_status(seq=%x. q=%d)\n", seq, q);
 
1722
 
 
1723
  return 0;
 
1724
}
 
1725
 
 
1726
/**
 
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
 
1730
 */
 
1731
int
 
1732
snd_seq_queue_status_malloc (snd_seq_queue_status_t ** ptr)
 
1733
{
 
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);
 
1737
  if (!*ptr)
 
1738
    return -ENOMEM;
 
1739
  return 0;
 
1740
}
 
1741
 
 
1742
/**
 
1743
 * \brief frees a previously allocated #snd_seq_queue_status_t
 
1744
 * \param pointer to object to free
 
1745
 */
 
1746
void
 
1747
snd_seq_queue_status_free (snd_seq_queue_status_t * obj)
 
1748
{
 
1749
  dbg_printf ("snd_seq_queue_status_free(%x)\n", obj);
 
1750
 
 
1751
  free (obj);
 
1752
}
 
1753
 
 
1754
/**
 
1755
 * \brief Get the tick time of a queue_status container
 
1756
 * \param info queue_status container
 
1757
 * \return tick time
 
1758
 *
 
1759
 * \sa snd_seq_get_queue_status()
 
1760
 */
 
1761
snd_seq_tick_time_t
 
1762
snd_seq_queue_status_get_tick_time (const snd_seq_queue_status_t * info)
 
1763
{
 
1764
  dbg_printf ("snd_seq_queue_status_get_tick_time(info=%x)\n", info);
 
1765
 
 
1766
  return 0;
 
1767
}
 
1768
 
 
1769
/**
 
1770
 * \brief get size of #snd_seq_remove_events_t
 
1771
 * \return size in bytes
 
1772
 */
 
1773
size_t
 
1774
snd_seq_remove_events_sizeof ()
 
1775
{
 
1776
  return sizeof (snd_seq_remove_events_t);
 
1777
}
 
1778
 
 
1779
/**
 
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
 
1783
 */
 
1784
int
 
1785
snd_seq_remove_events_malloc (snd_seq_remove_events_t ** ptr)
 
1786
{
 
1787
  assert (ptr);
 
1788
  *ptr = calloc (1, sizeof (snd_seq_remove_events_t));
 
1789
  dbg_printf ("snd_seq_remove_events_malloc()=%x\n", *ptr);
 
1790
  if (!*ptr)
 
1791
    return -ENOMEM;
 
1792
  return 0;
 
1793
}
 
1794
 
 
1795
/**
 
1796
 * \brief frees a previously allocated #snd_seq_remove_events_t
 
1797
 * \param pointer to object to free
 
1798
 */
 
1799
void
 
1800
snd_seq_remove_events_free (snd_seq_remove_events_t * obj)
 
1801
{
 
1802
  free (obj);
 
1803
}
 
1804
 
 
1805
/**
 
1806
 * \brief Set the removal condition bits
 
1807
 * \param info remove_events container
 
1808
 * \param flags removal condition bits
 
1809
 *
 
1810
 * \sa snd_seq_remove_events()
 
1811
 */
 
1812
void
 
1813
snd_seq_remove_events_set_condition (snd_seq_remove_events_t * info,
 
1814
                                     unsigned int flags)
 
1815
{
 
1816
  dbg_printf ("snd_seq_remove_events_set_condition(rmp=%x, flags=%lu)\n",
 
1817
              info, flags);
 
1818
}
 
1819
 
 
1820
/**
 
1821
 * \brief Set the queue as removal condition
 
1822
 * \param info remove_events container
 
1823
 * \param queue queue id
 
1824
 *
 
1825
 * \sa snd_seq_remove_events()
 
1826
 */
 
1827
void
 
1828
snd_seq_remove_events_set_queue (snd_seq_remove_events_t * info, int queue)
 
1829
{
 
1830
  dbg_printf ("snd_seq_remove_events_set_queue(rmp=%x, q=%d)\n", info, queue);
 
1831
}
 
1832
 
 
1833
/**
 
1834
 * \brief remove events on input/output buffers and pools
 
1835
 * \param seq sequencer handle
 
1836
 * \param rmp remove event container
 
1837
 *
 
1838
 * Removes matching events with the given condition from input/output buffers
 
1839
 * and pools.
 
1840
 * The removal condition is specified in \a rmp argument.
 
1841
 *
 
1842
 * \sa snd_seq_event_output(), snd_seq_drop_output(), snd_seq_reset_pool_output()
 
1843
 */
 
1844
int
 
1845
snd_seq_remove_events (snd_seq_t * seq, snd_seq_remove_events_t * rmp)
 
1846
{
 
1847
  dbg_printf ("snd_seq_remove_events(seq=%x, rmp=%x)\n", seq, rmp);
 
1848
 
 
1849
  return 1;
 
1850
}
 
1851
 
 
1852
 
 
1853
/**
 
1854
 * \brief clear input buffer and and remove events in sequencer queue
 
1855
 * \param seq sequencer handle
 
1856
 *
 
1857
 * \sa snd_seq_drop_input_buffer(), snd_seq_remove_events()
 
1858
 */
 
1859
int
 
1860
snd_seq_drop_input (snd_seq_t * seq)
 
1861
{
 
1862
  dbg_printf ("snd_seq_drop_input(seq=%x)\n", seq);
 
1863
 
 
1864
  return 0;
 
1865
}
 
1866
 
 
1867
/**
 
1868
 * \brief remove all events on user-space output buffer
 
1869
 * \param seq sequencer handle
 
1870
 *
 
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.
 
1874
 *
 
1875
 * \sa snd_seq_drop_output()
 
1876
 */
 
1877
int
 
1878
snd_seq_drop_output_buffer (snd_seq_t * seq)
 
1879
{
 
1880
  dbg_printf ("snd_seq_drop_output_buffer(seq=%x)\n", seq);
 
1881
 
 
1882
  return 0;
 
1883
}
 
1884
 
 
1885
/**
 
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
 
1890
 *
 
1891
 * Extracts the first event in output buffer.
 
1892
 * If ev_res is NULL, just remove the event.
 
1893
 *
 
1894
 * \sa snd_seq_event_output()
 
1895
 */
 
1896
int
 
1897
snd_seq_extract_output (snd_seq_t * seq, snd_seq_event_t ** ev_res)
 
1898
{
 
1899
  dbg_printf ("snd_seq_extract_output(seq=%x)\n", seq);
 
1900
 
 
1901
  return -EIO;
 
1902
}
 
1903
 
 
1904
/**
 
1905
 * \brief get size of #snd_seq_queue_status_t
 
1906
 * \return size in bytes
 
1907
 */
 
1908
size_t
 
1909
snd_seq_queue_status_sizeof ()
 
1910
{
 
1911
  return sizeof (snd_seq_queue_status_t);
 
1912
}
 
1913
 
 
1914
/**
 
1915
 * \brief Return the size of output buffer
 
1916
 * \param seq sequencer handle
 
1917
 * \return the size of output buffer in bytes
 
1918
 *
 
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.
 
1922
 *
 
1923
 * \sa snd_seq_set_output_buffer_size()
 
1924
 */
 
1925
size_t
 
1926
snd_seq_get_output_buffer_size (snd_seq_t * seq)
 
1927
{
 
1928
  dbg_printf ("snd_seq_get_output_buffer_size(seq=%x)\n", seq);
 
1929
 
 
1930
  return 1024;
 
1931
}
 
1932
 
 
1933
/**
 
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
 
1938
 *
 
1939
 * Changes the size of output buffer.
 
1940
 *
 
1941
 * \sa snd_seq_get_output_buffer_size()
 
1942
 */
 
1943
int
 
1944
snd_seq_set_output_buffer_size (snd_seq_t * seq, size_t size)
 
1945
{
 
1946
  dbg_printf ("snd_seq_set_output_buffer_size(seq=%x, size=%d)\n", seq, size);
 
1947
  return 0;
 
1948
}
 
1949
 
 
1950
/**
 
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
 
1955
 *
 
1956
 * Unsubscribes a connection between two ports,
 
1957
 * described in sender and dest fields in sub argument.
 
1958
 *
 
1959
 * \sa snd_seq_subscribe_port(), snd_seq_disconnect_from(), snd_seq_disconnect_to()
 
1960
 */
 
1961
int
 
1962
snd_seq_unsubscribe_port (snd_seq_t * seq, snd_seq_port_subscribe_t * sub)
 
1963
{
 
1964
  dbg_printf ("snd_seq_unsubscribe_port(seq=%x, sub=%x)\n", seq, sub);
 
1965
 
 
1966
  return 0;
 
1967
}
 
1968
 
 
1969
/**
 
1970
 * \brief Get the queue id of a queue_timer container
 
1971
 * \param info queue_timer container
 
1972
 * \return queue id
 
1973
 *
 
1974
 * \sa snd_seq_get_queue_timer()
 
1975
 */
 
1976
int
 
1977
snd_seq_queue_timer_get_queue (const snd_seq_queue_timer_t * info)
 
1978
{
 
1979
  dbg_printf ("snd_seq_queue_timer_get_queue(timer=%x)\n", info);
 
1980
 
 
1981
  return 0;
 
1982
}
 
1983
 
 
1984
/**
 
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
 
1990
 *
 
1991
 * \sa snd_seq_set_queue_timer()
 
1992
 */
 
1993
int
 
1994
snd_seq_get_queue_timer (snd_seq_t * seq, int q,
 
1995
                         snd_seq_queue_timer_t * timer)
 
1996
{
 
1997
  dbg_printf ("snd_seq_get_queue_timer(seq=%x, q=%d, timer=%x)\n",
 
1998
              seq, 1, timer);
 
1999
 
 
2000
  return 0;
 
2001
}
 
2002
 
 
2003
/**
 
2004
 * \brief Set the timer id of a queue_timer container
 
2005
 * \param info queue_timer container
 
2006
 * \param id timer id pointer
 
2007
 *
 
2008
 * \sa snd_seq_get_queue_timer()
 
2009
 */
 
2010
void
 
2011
snd_seq_queue_timer_set_id (snd_seq_queue_timer_t * info,
 
2012
                            const snd_timer_id_t * id)
 
2013
{
 
2014
  dbg_printf ("snd_seq_queue_timer_set_id(timer=%x, id=%x)\n", info, id);
 
2015
}
 
2016
 
 
2017
/**
 
2018
 * \brief get size of #snd_seq_queue_timer_t
 
2019
 * \return size in bytes
 
2020
 */
 
2021
size_t
 
2022
snd_seq_queue_timer_sizeof ()
 
2023
{
 
2024
  return sizeof (snd_seq_queue_timer_t);
 
2025
}
 
2026
 
 
2027
/**
 
2028
 * \brief get size of #snd_seq_query_subscribe_t
 
2029
 * \return size in bytes
 
2030
 */
 
2031
size_t
 
2032
snd_seq_query_subscribe_sizeof ()
 
2033
{
 
2034
  return sizeof (snd_seq_query_subscribe_t);
 
2035
}
 
2036
 
 
2037
/**
 
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
 
2041
 */
 
2042
int
 
2043
snd_seq_query_subscribe_malloc (snd_seq_query_subscribe_t ** ptr)
 
2044
{
 
2045
  *ptr = calloc (1, sizeof (snd_seq_query_subscribe_t));
 
2046
 
 
2047
  dbg_printf ("snd_seq_query_subscribe_malloc()=%x\n", *ptr);
 
2048
  if (!*ptr)
 
2049
    return -ENOMEM;
 
2050
  return 0;
 
2051
}
 
2052
 
 
2053
/**
 
2054
 * \brief frees a previously allocated #snd_seq_query_subscribe_t
 
2055
 * \param pointer to object to free
 
2056
 */
 
2057
void
 
2058
snd_seq_query_subscribe_free (snd_seq_query_subscribe_t * obj)
 
2059
{
 
2060
  dbg_printf ("snd_seq_query_subscribe_free(obj=%x)\n", obj);
 
2061
  free (obj);
 
2062
}
 
2063
 
 
2064
/**
 
2065
 * \brief Get the address of subscriber of a query_subscribe container
 
2066
 * \param info query_subscribe container
 
2067
 * \return subscriber's address pointer
 
2068
 *
 
2069
 * \sa snd_seq_query_port_subscribers()
 
2070
 */
 
2071
const snd_seq_addr_t *
 
2072
snd_seq_query_subscribe_get_addr (const snd_seq_query_subscribe_t * info)
 
2073
{
 
2074
  dbg_printf ("snd_seq_query_subscribe_get_addr(info=%x)\n", info);
 
2075
 
 
2076
  return NULL;                  // TODO
 
2077
}
 
2078
 
 
2079
/**
 
2080
 * \brief Get the index of subscriber of a query_subscribe container
 
2081
 * \param info query_subscribe container
 
2082
 * \return subscriber's index
 
2083
 *
 
2084
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_index()
 
2085
 */
 
2086
int
 
2087
snd_seq_query_subscribe_get_index (const snd_seq_query_subscribe_t * info)
 
2088
{
 
2089
  dbg_printf ("snd_seq_query_subscribe_get_index(info=%x)\n", info);
 
2090
 
 
2091
  return 0;                     // TODO
 
2092
}
 
2093
 
 
2094
/**
 
2095
 * \brief Set the subscriber's index to be queried
 
2096
 * \param info query_subscribe container
 
2097
 * \param index index to be queried
 
2098
 *
 
2099
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_index()
 
2100
 */
 
2101
void
 
2102
snd_seq_query_subscribe_set_index (snd_seq_query_subscribe_t * info,
 
2103
                                   int index)
 
2104
{
 
2105
  dbg_printf ("snd_seq_query_subscribe_t(info=%x, index=%d)\n", info, index);
 
2106
 
 
2107
  // TODO
 
2108
}
 
2109
 
 
2110
/**
 
2111
 * \brief Get the client/port address of a query_subscribe container
 
2112
 * \param info query_subscribe container
 
2113
 * \return client/port address pointer
 
2114
 *
 
2115
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_root()
 
2116
 */
 
2117
const snd_seq_addr_t *
 
2118
snd_seq_query_subscribe_get_root (const snd_seq_query_subscribe_t * info)
 
2119
{
 
2120
  dbg_printf ("snd_seq_query_subscribe_get_root(info=%x)\n", info);
 
2121
 
 
2122
  return NULL;                  // TODO
 
2123
}
 
2124
 
 
2125
/**
 
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
 
2129
 *
 
2130
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_root()
 
2131
 */
 
2132
void
 
2133
snd_seq_query_subscribe_set_root (snd_seq_query_subscribe_t * info,
 
2134
                                  const snd_seq_addr_t * addr)
 
2135
{
 
2136
  dbg_printf ("snd_seq_query_subscribe_set_root(info=%d, addr=%x)\n",
 
2137
              info, addr);
 
2138
}
 
2139
 
 
2140
/**
 
2141
 * \brief Get the query type of a query_subscribe container
 
2142
 * \param info query_subscribe container
 
2143
 * \return query type
 
2144
 *
 
2145
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_set_type()
 
2146
 */
 
2147
snd_seq_query_subs_type_t
 
2148
snd_seq_query_subscribe_get_type (const snd_seq_query_subscribe_t * info)
 
2149
{
 
2150
  dbg_printf ("snd_seq_query_subscribe_get_type(info=%x)\n", info);
 
2151
 
 
2152
  return 0;                     // TODO
 
2153
}
 
2154
 
 
2155
/**
 
2156
 * \brief Set the query type of a query_subscribe container
 
2157
 * \param info query_subscribe container
 
2158
 * \param type query type
 
2159
 *
 
2160
 * \sa snd_seq_query_port_subscribers(), snd_seq_query_subscribe_get_type()
 
2161
 */
 
2162
void
 
2163
snd_seq_query_subscribe_set_type (snd_seq_query_subscribe_t * info,
 
2164
                                  snd_seq_query_subs_type_t type)
 
2165
{
 
2166
  dbg_printf ("snd_seq_query_subscribe_set_type(info=%x, type=%x)\n",
 
2167
              info, type);
 
2168
 
 
2169
  // TODO
 
2170
}
 
2171
 
 
2172
/**
 
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
 
2177
 *
 
2178
 * \sa snd_seq_subscribe_port(), snd_seq_query_port_subscribers()
 
2179
 */
 
2180
int
 
2181
snd_seq_get_port_subscription (snd_seq_t * seq,
 
2182
                               snd_seq_port_subscribe_t * sub)
 
2183
{
 
2184
  dbg_printf ("snd_seq_get_port_subscription(seq=%x, sub=%x)\n", seq, sub);
 
2185
 
 
2186
  return 0;                     // TODO
 
2187
}
 
2188
 
 
2189
/**
 
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
 
2194
 *
 
2195
 * Queries the subscribers accessing to a port.
 
2196
 * The query information is specified in subs argument.
 
2197
 *
 
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.
 
2205
 *
 
2206
 * \sa snd_seq_get_port_subscription()
 
2207
 */
 
2208
int
 
2209
snd_seq_query_port_subscribers (snd_seq_t * seq, snd_seq_query_subscribe_t *
 
2210
                                subs)
 
2211
{
 
2212
  dbg_printf ("snd_seq_query_port_subscribers(seq=%x, subs=%x)\n", seq, subs);
 
2213
 
 
2214
  return 0;                     // TODO
 
2215
}
 
2216
 
 
2217
/**
 
2218
 * \brief Get the real time of a queue_status container
 
2219
 * \param info queue_status container
 
2220
 * \param time real time
 
2221
 *
 
2222
 * \sa snd_seq_get_queue_status()
 
2223
 */
 
2224
const snd_seq_real_time_t *
 
2225
snd_seq_queue_status_get_real_time (const snd_seq_queue_status_t * info)
 
2226
{
 
2227
  dbg_printf ("snd_seq_queue_status_get_real_time(info=%x)\n", info);
 
2228
 
 
2229
  return NULL;                  // TODO
 
2230
}