diff options
author | 2011-11-15 08:05:22 +0000 | |
---|---|---|
committer | 2011-11-15 08:05:22 +0000 | |
commit | b395609868171dda79778399742da4042c7d40db (patch) | |
tree | f4f72c7c677213b01364f957b5ac3d13fa3811dd /lib/libsndio/sio.c | |
parent | Don't do non-512 writes to vnd. ok matthew (diff) | |
download | wireguard-openbsd-b395609868171dda79778399742da4042c7d40db.tar.xz wireguard-openbsd-b395609868171dda79778399742da4042c7d40db.zip |
Add a "device number" component in sndio(7) device names, allowing a
single aucat instance to handle all audio and MIDI services. Since
this partially breaks compatibility, this is a opportunitiy to fix few
other design mistakes (eg ':' being used by inet6, type name vs api
name confusion, etc..). This leads to the following names:
type[@hostname][,unit]/devnum[.option]
The device number is the minor device number for direct hardware
access (ie the 'N' in /dev/audioN). For aucat, this is the occurence
number of the -f (or -M) option.
There's a compatibility hook to keep old names working if only one
aucat server is running.
Diffstat (limited to 'lib/libsndio/sio.c')
-rw-r--r-- | lib/libsndio/sio.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/lib/libsndio/sio.c b/lib/libsndio/sio.c index 1b1376c7d4f..65a94624300 100644 --- a/lib/libsndio/sio.c +++ b/lib/libsndio/sio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio.c,v 1.6 2011/05/09 17:34:14 ratchov Exp $ */ +/* $OpenBSD: sio.c,v 1.7 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -33,17 +33,6 @@ #define SIO_PAR_MAGIC 0x83b905a4 -struct sio_backend { - char *prefix; - struct sio_hdl *(*open)(const char *, unsigned, int); -}; - -static struct sio_backend backends[] = { - { "aucat", sio_aucat_open }, - { "sun", sio_sun_open }, - { NULL, NULL } -}; - void sio_initpar(struct sio_par *par) { @@ -54,10 +43,8 @@ sio_initpar(struct sio_par *par) struct sio_hdl * sio_open(const char *str, unsigned mode, int nbio) { - struct sio_backend *b; struct sio_hdl *hdl; - char *sep; - int len; + const char *p; #ifdef DEBUG sndio_debug_init(); @@ -67,22 +54,17 @@ sio_open(const char *str, unsigned mode, int nbio) if (str == NULL && !issetugid()) str = getenv("AUDIODEVICE"); if (str == NULL) { - for (b = backends; b->prefix != NULL; b++) { - hdl = b->open(NULL, mode, nbio); - if (hdl != NULL) - return hdl; - } - return NULL; - } - sep = strchr(str, ':'); - if (sep == NULL) { - DPRINTF("sio_open: %s: ':' missing in device name\n", str); - return NULL; + hdl = sio_aucat_open("/0", mode, nbio); + if (hdl != NULL) + return hdl; + return sio_sun_open("/", mode, nbio); } - len = sep - str; - for (b = backends; b->prefix != NULL; b++) { - if (strlen(b->prefix) == len && memcmp(b->prefix, str, len) == 0) - return b->open(sep + 1, mode, nbio); + if ((p = sndio_parsetype(str, "snd")) != NULL || + (p = sndio_parsetype(str, "aucat")) != NULL) + return sio_aucat_open(p, mode, nbio); + if ((p = sndio_parsetype(str, "rsnd")) != NULL || + (p = sndio_parsetype(str, "sun")) != NULL) { + return sio_sun_open(p, mode, nbio); } DPRINTF("sio_open: %s: unknown device type\n", str); return NULL; |