diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-11-15 08:05:23 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2011-11-15 08:05:23 +0000 |
commit | 1d03551d3bdde57b6b26304c15d01e24fa830fd2 (patch) | |
tree | f427bbcfc086b18d7aae9e6201af95c20d4779ac /lib/libsndio | |
parent | 231448b73ea84fb6b44a1e2fad2383a7ae09872d (diff) |
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')
-rw-r--r-- | lib/libsndio/amsg.h | 8 | ||||
-rw-r--r-- | lib/libsndio/aucat.c | 133 | ||||
-rw-r--r-- | lib/libsndio/aucat.h | 2 | ||||
-rw-r--r-- | lib/libsndio/debug.c | 16 | ||||
-rw-r--r-- | lib/libsndio/debug.h | 11 | ||||
-rw-r--r-- | lib/libsndio/mio.c | 34 | ||||
-rw-r--r-- | lib/libsndio/mio_aucat.c | 6 | ||||
-rw-r--r-- | lib/libsndio/mio_priv.h | 4 | ||||
-rw-r--r-- | lib/libsndio/mio_rmidi.c | 11 | ||||
-rw-r--r-- | lib/libsndio/sio.c | 42 | ||||
-rw-r--r-- | lib/libsndio/sio_aucat.c | 8 | ||||
-rw-r--r-- | lib/libsndio/sio_sun.c | 13 | ||||
-rw-r--r-- | lib/libsndio/sndio.7 | 90 |
13 files changed, 218 insertions, 160 deletions
diff --git a/lib/libsndio/amsg.h b/lib/libsndio/amsg.h index 2cf7dd04e4b..585b1be8ce2 100644 --- a/lib/libsndio/amsg.h +++ b/lib/libsndio/amsg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amsg.h,v 1.3 2011/10/17 21:09:11 ratchov Exp $ */ +/* $OpenBSD: amsg.h,v 1.4 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -82,8 +82,10 @@ struct amsg { uint16_t mode; /* bitmap of MODE_XXX */ #define AMSG_VERSION 5 uint8_t version; /* protocol version */ - uint8_t reserved1[5]; /* for future use */ - char opt[12]; /* profile name */ + uint8_t devnum; /* device number */ + uint32_t _reserved[1]; /* for future use */ +#define AMSG_OPTMAX 12 + char opt[AMSG_OPTMAX]; /* profile name */ char who[12]; /* hint for leases */ } hello; struct amsg_auth { diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c index b7061ec3bd3..198b163e3a1 100644 --- a/lib/libsndio/aucat.c +++ b/lib/libsndio/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.52 2011/10/22 10:23:44 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.53 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -149,7 +149,7 @@ aucat_rdata(struct aucat *hdl, void *buf, size_t len, int *eof) hdl->rstate = RSTATE_MSG; hdl->rtodo = sizeof(struct amsg); } - DPRINTF("aucat_rdata: read: n = %zd\n", n); + DPRINTFN(2, "aucat_rdata: read: n = %zd\n", n); return n; } @@ -191,7 +191,7 @@ aucat_wdata(struct aucat *hdl, const void *buf, size_t len, unsigned wbpf, int * } return 0; } - DPRINTF("aucat_wdata: write: n = %zd\n", n); + DPRINTFN(2, "aucat_wdata: write: n = %zd\n", n); hdl->wtodo -= n; if (hdl->wtodo == 0) { hdl->wstate = WSTATE_IDLE; @@ -282,18 +282,13 @@ bad_gen: } int -aucat_connect_tcp(struct aucat *hdl, char *host, char *unit) +aucat_connect_tcp(struct aucat *hdl, char *host, unsigned unit) { int s, error, opt; struct addrinfo *ailist, *ai, aihints; - unsigned port; char serv[NI_MAXSERV]; - if (sscanf(unit, "%u", &port) != 1) { - DPRINTF("%s: bad unit number\n", unit); - return 0; - } - snprintf(serv, sizeof(serv), "%u", port + AUCAT_PORT); + snprintf(serv, sizeof(serv), "%u", unit + AUCAT_PORT); memset(&aihints, 0, sizeof(struct addrinfo)); aihints.ai_socktype = SOCK_STREAM; aihints.ai_protocol = IPPROTO_TCP; @@ -334,7 +329,7 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit) } int -aucat_connect_un(struct aucat *hdl, char *unit) +aucat_connect_un(struct aucat *hdl, unsigned unit) { struct sockaddr_un ca; socklen_t len = sizeof(struct sockaddr_un); @@ -343,7 +338,7 @@ aucat_connect_un(struct aucat *hdl, char *unit) uid = geteuid(); snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat-%u/%s%s", uid, AUCAT_PATH, unit); + "/tmp/aucat-%u/%s%u", uid, AUCAT_PATH, unit); ca.sun_family = AF_UNIX; s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) @@ -354,7 +349,7 @@ aucat_connect_un(struct aucat *hdl, char *unit) DPERROR(ca.sun_path); /* try shared server */ snprintf(ca.sun_path, sizeof(ca.sun_path), - "/tmp/aucat/%s%s", AUCAT_PATH, unit); + "/tmp/aucat/%s%u", AUCAT_PATH, unit); while (connect(s, (struct sockaddr *)&ca, len) < 0) { if (errno == EINTR) continue; @@ -368,43 +363,90 @@ aucat_connect_un(struct aucat *hdl, char *unit) return 1; } +static const char * +parsedev(const char *str, unsigned *rval) +{ + const char *p = str; + unsigned val; + + for (val = 0; *p >= '0' && *p <= '9'; p++) { + val = 10 * val + (*p - '0'); + if (val >= 16) { + DPRINTF("%s: number too large\n", str); + return NULL; + } + } + if (p == str) { + DPRINTF("%s: number expected\n", str); + return NULL; + } + *rval = val; + return p; +} + +static const char * +parsestr(const char *str, char *rstr, unsigned max) +{ + const char *p = str; + + while (*p != '\0' && *p != ',' && *p != '/') { + if (--max == 0) { + DPRINTF("%s: string too long\n", str); + return NULL; + } + *rstr++ = *p++; + } + if (str == p) { + DPRINTF("%s: string expected\n", str); + return NULL; + } + *rstr = '\0'; + return p; +} + int -aucat_open(struct aucat *hdl, const char *str, unsigned mode) +aucat_open(struct aucat *hdl, const char *str, unsigned mode, unsigned type) { extern char *__progname; - int eof, hashost; - char unit[4], *sep, *opt; - char host[NI_MAXHOST]; - - if (str == NULL) - str = "0"; - sep = strchr(str, '/'); - if (sep == NULL) { - hashost = 0; - } else { - if (sep - str >= sizeof(host)) { - DPRINTF("aucat_open: %s: host too long\n", str); + int eof; + char host[NI_MAXHOST], opt[AMSG_OPTMAX]; + const char *p = str; + unsigned unit, devnum; + + if (*p == '@') { + p = parsestr(++p, host, NI_MAXHOST); + if (p == NULL) return 0; - } - memcpy(host, str, sep - str); - host[sep - str] = '\0'; - hashost = 1; - str = sep + 1; - } - sep = strchr(str, '.'); - if (sep == NULL) { - opt = "default"; - strlcpy(unit, str, sizeof(unit)); - } else { - opt = sep + 1; - if (sep - str >= sizeof(unit)) { - DPRINTF("aucat_init: %s: too long\n", str); + } else + *host = '\0'; + if (*p == ',') { + p = parsedev(++p, &unit); + if (p == NULL) return 0; - } - strlcpy(unit, str, opt - str); + } else + unit = 0; + if (*p != '/' && *p != ':') { + DPRINTF("%s: '/' expected\n", str); + return 0; + } + p = parsedev(++p, &devnum); + if (p == NULL) + return 0; + if (*p == '.') { + p = parsestr(++p, opt, AMSG_OPTMAX); + if (p == NULL) + return 0; + } else + strlcpy(opt, "default", AMSG_OPTMAX); + if (*p != '\0') { + DPRINTF("%s: junk at end of dev name\n", p); + return 0; } - DPRINTF("aucat_init: trying %s -> %s.%s\n", str, unit, opt); - if (hashost) { + if (type) + devnum += 16; /* XXX */ + DPRINTF("aucat_open: host=%s unit=%u devnum=%u opt=%s\n", + host, unit, devnum, opt); + if (host[0] != '\0') { if (!aucat_connect_tcp(hdl, host, unit)) return 0; } else { @@ -434,6 +476,7 @@ aucat_open(struct aucat *hdl, const char *str, unsigned mode) hdl->wmsg.cmd = htonl(AMSG_HELLO); hdl->wmsg.u.hello.version = AMSG_VERSION; hdl->wmsg.u.hello.mode = htons(mode); + hdl->wmsg.u.hello.devnum = devnum; strlcpy(hdl->wmsg.u.hello.who, __progname, sizeof(hdl->wmsg.u.hello.who)); strlcpy(hdl->wmsg.u.hello.opt, opt, @@ -502,6 +545,6 @@ aucat_revents(struct aucat *hdl, struct pollfd *pfd) { int revents = pfd->revents; - DPRINTF("aucat_revents: revents: %x\n", revents); + DPRINTFN(2, "aucat_revents: revents: %x\n", revents); return revents; } diff --git a/lib/libsndio/aucat.h b/lib/libsndio/aucat.h index 6598d70aadb..42dc89f85e7 100644 --- a/lib/libsndio/aucat.h +++ b/lib/libsndio/aucat.h @@ -20,7 +20,7 @@ int aucat_rmsg(struct aucat *, int *); int aucat_wmsg(struct aucat *, int *); size_t aucat_rdata(struct aucat *, void *, size_t, int *); size_t aucat_wdata(struct aucat *, const void *, size_t, unsigned, int *); -int aucat_open(struct aucat *, const char *, unsigned); +int aucat_open(struct aucat *, const char *, unsigned, unsigned); void aucat_close(struct aucat *, int); int aucat_pollfd(struct aucat *, struct pollfd *, int); int aucat_revents(struct aucat *, struct pollfd *); diff --git a/lib/libsndio/debug.c b/lib/libsndio/debug.c index 05431cc6b3e..b592506494d 100644 --- a/lib/libsndio/debug.c +++ b/lib/libsndio/debug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.c,v 1.1 2011/04/16 10:52:22 ratchov Exp $ */ +/* $OpenBSD: debug.c,v 1.2 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2011 Alexandre Ratchov <alex@caoua.org> * @@ -39,3 +39,17 @@ sndio_debug_init(void) } } #endif + +const char * +sndio_parsetype(const char *str, char *type) +{ + while (*type) { + if (*type != *str) + return NULL; + type++; + str++; + } + if (*str >= 'a' && *str <= 'z') + return NULL; + return str; +} diff --git a/lib/libsndio/debug.h b/lib/libsndio/debug.h index 53265f68550..4d3baf40eef 100644 --- a/lib/libsndio/debug.h +++ b/lib/libsndio/debug.h @@ -1,4 +1,4 @@ -/* $OpenBSD: debug.h,v 1.1 2011/04/16 10:52:22 ratchov Exp $ */ +/* $OpenBSD: debug.h,v 1.2 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -20,6 +20,12 @@ #ifdef DEBUG #include <stdio.h> +#define DPRINTFN(n, ...) \ + do { \ + if (sndio_debug >= (n)) \ + fprintf(stderr, __VA_ARGS__); \ + } while(0) + #define DPRINTF(...) \ do { \ if (sndio_debug > 0) \ @@ -36,7 +42,10 @@ void sndio_debug_init(void); extern int sndio_debug; #else #define DPRINTF(...) do {} while(0) +#define DPRINTFN(...) do {} while(0) #define DPERROR(s) do {} while(0) #endif +const char *sndio_parsetype(const char *, char *); + #endif diff --git a/lib/libsndio/mio.c b/lib/libsndio/mio.c index 55631863df3..c1d28ee9e54 100644 --- a/lib/libsndio/mio.c +++ b/lib/libsndio/mio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio.c,v 1.12 2011/10/17 21:09:11 ratchov Exp $ */ +/* $OpenBSD: mio.c,v 1.13 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -34,12 +34,8 @@ struct mio_hdl * mio_open(const char *str, unsigned mode, int nbio) { - static char prefix_midithru[] = "midithru"; - static char prefix_rmidi[] = "rmidi"; - static char prefix_aucat[] = "aucat"; struct mio_hdl *hdl; - char *sep; - int len; + const char *p; #ifdef DEBUG sndio_debug_init(); @@ -49,26 +45,18 @@ mio_open(const char *str, unsigned mode, int nbio) if (str == NULL && !issetugid()) str = getenv("MIDIDEVICE"); if (str == NULL) { - hdl = mio_aucat_open("0", mode, nbio); + hdl = mio_aucat_open("/0", mode, nbio, 1); if (hdl != NULL) return hdl; - return mio_rmidi_open("0", mode, nbio); + return mio_rmidi_open("/0", mode, nbio); } - sep = strchr(str, ':'); - if (sep == NULL) { - DPRINTF("mio_open: %s: ':' missing in device name\n", str); - return NULL; - } - len = sep - str; - if (len == (sizeof(prefix_midithru) - 1) && - memcmp(str, prefix_midithru, len) == 0) - return mio_aucat_open(sep + 1, mode, nbio); - if (len == (sizeof(prefix_aucat) - 1) && - memcmp(str, prefix_aucat, len) == 0) - return mio_aucat_open(sep + 1, mode, nbio); - if (len == (sizeof(prefix_rmidi) - 1) && - memcmp(str, prefix_rmidi, len) == 0) - return mio_rmidi_open(sep + 1, mode, nbio); + if ((p = sndio_parsetype(str, "snd")) != NULL || + (p = sndio_parsetype(str, "aucat")) != NULL) + return mio_aucat_open(p, mode, nbio, 0); + if ((p = sndio_parsetype(str, "midithru")) != NULL) + return mio_aucat_open(p, mode, nbio, 1); + if ((p = sndio_parsetype(str, "rmidi")) != NULL) + return mio_rmidi_open(p, mode, nbio); DPRINTF("mio_open: %s: unknown device type\n", str); return NULL; } diff --git a/lib/libsndio/mio_aucat.c b/lib/libsndio/mio_aucat.c index 5c2e55450fe..501fc95a258 100644 --- a/lib/libsndio/mio_aucat.c +++ b/lib/libsndio/mio_aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_aucat.c,v 1.5 2011/10/17 21:09:11 ratchov Exp $ */ +/* $OpenBSD: mio_aucat.c,v 1.6 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -52,14 +52,14 @@ static struct mio_ops mio_aucat_ops = { }; struct mio_hdl * -mio_aucat_open(const char *str, unsigned mode, int nbio) +mio_aucat_open(const char *str, unsigned mode, int nbio, unsigned type) { struct mio_aucat_hdl *hdl; hdl = malloc(sizeof(struct mio_aucat_hdl)); if (hdl == NULL) return NULL; - if (!aucat_open(&hdl->aucat, str, mode)) + if (!aucat_open(&hdl->aucat, str, mode, type)) goto bad; mio_create(&hdl->mio, &mio_aucat_ops, mode, nbio); if (!aucat_setfl(&hdl->aucat, nbio, &hdl->mio.eof)) diff --git a/lib/libsndio/mio_priv.h b/lib/libsndio/mio_priv.h index dd22ca80bce..60efc2b7733 100644 --- a/lib/libsndio/mio_priv.h +++ b/lib/libsndio/mio_priv.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_priv.h,v 1.7 2011/10/17 21:09:11 ratchov Exp $ */ +/* $OpenBSD: mio_priv.h,v 1.8 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -42,7 +42,7 @@ struct mio_ops { }; struct mio_hdl *mio_rmidi_open(const char *, unsigned, int); -struct mio_hdl *mio_aucat_open(const char *, unsigned, int); +struct mio_hdl *mio_aucat_open(const char *, unsigned, int, unsigned); void mio_create(struct mio_hdl *, struct mio_ops *, unsigned, int); void mio_destroy(struct mio_hdl *); diff --git a/lib/libsndio/mio_rmidi.c b/lib/libsndio/mio_rmidi.c index b40584a0bfc..c638bf98ffd 100644 --- a/lib/libsndio/mio_rmidi.c +++ b/lib/libsndio/mio_rmidi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mio_rmidi.c,v 1.9 2011/04/16 10:52:22 ratchov Exp $ */ +/* $OpenBSD: mio_rmidi.c,v 1.10 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -56,6 +56,15 @@ mio_rmidi_open(const char *str, unsigned mode, int nbio) struct mio_rmidi_hdl *hdl; char path[PATH_MAX]; + switch (*str) { + case '/': + case ':': /* XXX: for backward compat */ + str++; + break; + default: + DPRINTF("sio_sun_open: %s: '/<devnum>' expected\n", str); + return NULL; + } hdl = malloc(sizeof(struct mio_rmidi_hdl)); if (hdl == NULL) return NULL; 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; diff --git a/lib/libsndio/sio_aucat.c b/lib/libsndio/sio_aucat.c index 2fbdea23492..2a97b878930 100644 --- a/lib/libsndio/sio_aucat.c +++ b/lib/libsndio/sio_aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio_aucat.c,v 1.8 2011/10/17 21:09:11 ratchov Exp $ */ +/* $OpenBSD: sio_aucat.c,v 1.9 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -109,7 +109,7 @@ sio_aucat_runmsg(struct sio_aucat_hdl *hdl) delta = ntohl(hdl->aucat.rmsg.u.ts.delta); hdl->maxwrite += delta * hdl->wbpf; hdl->delta += delta; - DPRINTF("aucat: move = %d, delta = %d, maxwrite = %d\n", + DPRINTFN(2, "aucat: move = %d, delta = %d, maxwrite = %d\n", delta, hdl->delta, hdl->maxwrite); if (hdl->delta >= 0) { sio_onmove_cb(&hdl->sio, hdl->delta); @@ -156,7 +156,7 @@ sio_aucat_open(const char *str, unsigned mode, int nbio) hdl = malloc(sizeof(struct sio_aucat_hdl)); if (hdl == NULL) return NULL; - if (!aucat_open(&hdl->aucat, str, mode)) { + if (!aucat_open(&hdl->aucat, str, mode, 0)) { free(hdl); return NULL; } @@ -466,7 +466,7 @@ sio_aucat_revents(struct sio_hdl *sh, struct pollfd *pfd) } if (hdl->sio.eof) return POLLHUP; - DPRINTF("sio_aucat_revents: %x\n", revents & hdl->events); + DPRINTFN(2, "sio_aucat_revents: %x\n", revents & hdl->events); return revents & (hdl->events | POLLHUP); } diff --git a/lib/libsndio/sio_sun.c b/lib/libsndio/sio_sun.c index 84e41f87d96..e02babc2117 100644 --- a/lib/libsndio/sio_sun.c +++ b/lib/libsndio/sio_sun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio_sun.c,v 1.3 2011/05/03 20:15:23 ratchov Exp $ */ +/* $OpenBSD: sio_sun.c,v 1.4 2011/11/15 08:05:22 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -343,8 +343,15 @@ sio_sun_open(const char *str, unsigned mode, int nbio) struct sio_par par; char path[PATH_MAX]; - if (str == NULL) - str = ""; + switch (*str) { + case '/': + case ':': /* XXX: for backward compat */ + str++; + break; + default: + DPRINTF("sio_sun_open: %s: '/<devnum>' expected\n", str); + return NULL; + } hdl = malloc(sizeof(struct sio_sun_hdl)); if (hdl == NULL) return NULL; diff --git a/lib/libsndio/sndio.7 b/lib/libsndio/sndio.7 index 98c58f2c357..6336cb6e739 100644 --- a/lib/libsndio/sndio.7 +++ b/lib/libsndio/sndio.7 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sndio.7,v 1.7 2011/10/18 07:07:25 jmc Exp $ +.\" $OpenBSD: sndio.7,v 1.8 2011/11/15 08:05:22 ratchov Exp $ .\" .\" Copyright (c) 2007 Alexandre Ratchov <alex@caoua.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: October 18 2011 $ +.Dd $Mdocdate: November 15 2011 $ .Dt SNDIO 7 .Os .Sh NAME @@ -68,73 +68,77 @@ From the user's perspective every audio interface, MIDI port, and .Xr aucat 1 service has a name of the form: .Bd -literal -offset center -type:[hostname/]unit[.option] +type[@hostname][,unit]/devnum[.option] .Ed .Pp This information is used by audio and MIDI applications to determine how to access the audio device or MIDI port. -.Bl -tag -width "option" +.Bl -tag -width "hostname" .It Pa type The type of the audio device or MIDI port. -Possible values for audio devices are -.Pa aucat -and -.Pa sun , -corresponding to -.Xr aucat 1 -sockets and hardware +Possible values are: +.Pp +.Bl -tag -width "midithru" -offset 3n -compact +.It Pa rsnd +Raw .Xr audio 4 -devices. -Possible values for MIDI ports are -.Pa aucat -and -.Pa rmidi -corresponding to -.Xr aucat 1 -software MIDI thru boxes or control ports and hardware +device. +.It Pa rmidi +Raw .Xr midi 4 -ports respectively. +port. +.It Pa snd +Audio device exposed by +.Xr aucat 1 . +.It Pa midithru +MIDI thru box created with +.Xr aucat 1 . +.El .It Pa hostname -The hostname where the remote +The hostname or address where the remote .Xr aucat 1 server to connect to is running. .It Pa unit +The number of the +.Xr aucat 1 +server to connect to, corresponding to the integer specified using the +.Fl U +option of +.Xr aucat 1 . +Useful only if multiple +.Xr aucat 1 +servers are running on the same system. +.It Pa devnum +Device number. For hardware audio or MIDI ports, this corresponds to the character device minor number. For audio devices or MIDI ports created with .Xr aucat 1 -it corresponds to the server -.Em unit -number, typically 0. +it corresponds to the number of the corresponding +.Fl fM +option on the command line. .It Pa option -Corresponds to the profile string registered using the +Corresponds to the sub-device string registered using the .Fl s option of .Xr aucat 1 . -Only meaningful for -.Pa aucat -device types. .El .Pp For example: .Pp -.Bl -tag -width "aucat:0.rear" -offset 3n -compact -.It Pa sun:0 +.Bl -tag -width "snd/0.rear" -offset 3n -compact +.It Pa rsnd/0 First hardware audio device. -.It Pa aucat:0 -Default audio device of the first -.Xr aucat 1 -audio server. -.It Pa aucat:0.rear -First -.Xr aucat 1 -server; -device registered with -.Fl s Fa rear . -.It Pa rmidi:5 +.It Pa rmidi/5 Hardware MIDI port number 5. -.It Pa aucat:0 -First software MIDI thru box or control port created with +.It Pa snd/0 +First audio device exposed by +.Xr aucat 1 . +.It Pa snd/0.rear +Sub-device registered with +.Fl s Fa rear . +.It Pa midithru/0 +First MIDI thru box created with .Xr aucat 1 . .El .Sh AUTHENTICATION |