summaryrefslogtreecommitdiff
path: root/lib/libsndio/aucat.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libsndio/aucat.c')
-rw-r--r--lib/libsndio/aucat.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/libsndio/aucat.c b/lib/libsndio/aucat.c
index 6936a912ac6..7c563ea8ddb 100644
--- a/lib/libsndio/aucat.c
+++ b/lib/libsndio/aucat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: aucat.c,v 1.50 2011/10/05 16:15:43 ratchov Exp $ */
+/* $OpenBSD: aucat.c,v 1.51 2011/10/17 21:09:11 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -280,7 +280,7 @@ bad_gen:
}
int
-aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
+aucat_connect_tcp(struct aucat *hdl, char *host, char *unit)
{
int s, error, opt;
struct addrinfo *ailist, *ai, aihints;
@@ -291,11 +291,7 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
DPRINTF("%s: bad unit number\n", unit);
return 0;
}
- if (isaudio)
- port += AUCAT_PORT;
- else
- port += MIDICAT_PORT;
- snprintf(serv, sizeof(serv), "%u", port);
+ snprintf(serv, sizeof(serv), "%u", port + AUCAT_PORT);
memset(&aihints, 0, sizeof(struct addrinfo));
aihints.ai_socktype = SOCK_STREAM;
aihints.ai_protocol = IPPROTO_TCP;
@@ -336,18 +332,16 @@ aucat_connect_tcp(struct aucat *hdl, char *host, char *unit, int isaudio)
}
int
-aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
+aucat_connect_un(struct aucat *hdl, char *unit)
{
struct sockaddr_un ca;
socklen_t len = sizeof(struct sockaddr_un);
- char *sock;
uid_t uid;
int s;
uid = geteuid();
- sock = isaudio ? AUCAT_PATH : MIDICAT_PATH;
snprintf(ca.sun_path, sizeof(ca.sun_path),
- "/tmp/aucat-%u/%s%s", uid, sock, unit);
+ "/tmp/aucat-%u/%s%s", uid, AUCAT_PATH, unit);
ca.sun_family = AF_UNIX;
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0)
@@ -358,7 +352,7 @@ aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
DPERROR(ca.sun_path);
/* try shared server */
snprintf(ca.sun_path, sizeof(ca.sun_path),
- "/tmp/aucat/%s%s", sock, unit);
+ "/tmp/aucat/%s%s", AUCAT_PATH, unit);
while (connect(s, (struct sockaddr *)&ca, len) < 0) {
if (errno == EINTR)
continue;
@@ -373,7 +367,7 @@ aucat_connect_un(struct aucat *hdl, char *unit, int isaudio)
}
int
-aucat_open(struct aucat *hdl, const char *str, unsigned mode, int isaudio)
+aucat_open(struct aucat *hdl, const char *str, unsigned mode)
{
extern char *__progname;
int eof, hashost;
@@ -409,10 +403,10 @@ aucat_open(struct aucat *hdl, const char *str, unsigned mode, int isaudio)
}
DPRINTF("aucat_init: trying %s -> %s.%s\n", str, unit, opt);
if (hashost) {
- if (!aucat_connect_tcp(hdl, host, unit, isaudio))
+ if (!aucat_connect_tcp(hdl, host, unit))
return 0;
} else {
- if (!aucat_connect_un(hdl, unit, isaudio))
+ if (!aucat_connect_un(hdl, unit))
return 0;
}
if (fcntl(hdl->fd, F_SETFD, FD_CLOEXEC) < 0) {