diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-16 18:34:57 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-16 18:34:57 +0000 |
commit | 2c17af8b4c81ae87457584b92800ef65dd1fdabc (patch) | |
tree | f88bcbb72df06bffe94d4dbe717831dac65dfc24 | |
parent | cb6a1d53a851bf092586108f475e833a229bbdc0 (diff) |
add ``template'' parameters to sockets rather than using device
parameters. No functional change.
-rw-r--r-- | usr.bin/aucat/aucat.c | 4 | ||||
-rw-r--r-- | usr.bin/aucat/listen.c | 10 | ||||
-rw-r--r-- | usr.bin/aucat/listen.h | 10 | ||||
-rw-r--r-- | usr.bin/aucat/sock.c | 46 | ||||
-rw-r--r-- | usr.bin/aucat/sock.h | 7 |
5 files changed, 49 insertions, 28 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index d6860be706d..d6cf1dcc0ff 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.40 2008/11/16 16:30:22 ratchov Exp $ */ +/* $OpenBSD: aucat.c,v 1.41 2008/11/16 18:34:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -465,7 +465,7 @@ main(int argc, char **argv) if (!listenpath) listenpath = DEFAULT_SOCKET; (void)listen_new(&listen_ops, listenpath, - MIDI_TO_ADATA(volctl)); + &dipar, &dopar, MIDI_TO_ADATA(volctl)); } /* diff --git a/usr.bin/aucat/listen.c b/usr.bin/aucat/listen.c index 5c10217289b..ce76e5787b7 100644 --- a/usr.bin/aucat/listen.c +++ b/usr.bin/aucat/listen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: listen.c,v 1.3 2008/11/16 16:30:22 ratchov Exp $ */ +/* $OpenBSD: listen.c,v 1.4 2008/11/16 18:34:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -46,7 +46,8 @@ struct fileops listen_ops = { }; struct listen * -listen_new(struct fileops *ops, char *path, int maxweight) +listen_new(struct fileops *ops, char *path, + struct aparams *wpar, struct aparams *rpar, int maxweight) { int sock; struct sockaddr_un sockname; @@ -83,6 +84,8 @@ listen_new(struct fileops *ops, char *path, int maxweight) exit(1); } f->fd = sock; + f->wpar = *wpar; + f->rpar = *rpar; f->maxweight = maxweight; return f; } @@ -123,7 +126,8 @@ listen_revents(struct file *file, struct pollfd *pfd) close(sock); return 0; } - (void)sock_new(&sock_ops, sock, "socket", f->maxweight); + (void)sock_new(&sock_ops, sock, "socket", + &f->wpar, &f->rpar, f->maxweight); } return 0; } diff --git a/usr.bin/aucat/listen.h b/usr.bin/aucat/listen.h index 298daee825a..dec41553ad1 100644 --- a/usr.bin/aucat/listen.h +++ b/usr.bin/aucat/listen.h @@ -1,4 +1,4 @@ -/* $OpenBSD: listen.h,v 1.2 2008/11/16 16:30:22 ratchov Exp $ */ +/* $OpenBSD: listen.h,v 1.3 2008/11/16 18:34:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -20,17 +20,21 @@ #include <sys/types.h> #include "file.h" +#include "aparams.h" struct listen { struct file file; char *path; int fd; int maxweight; /* max dynamic range for clients */ + struct aparams wpar; /* template for clients write params */ + struct aparams rpar; /* template for clients read params */ }; -struct listen *listen_new(struct fileops *, char *, int); +struct listen *listen_new(struct fileops *, char *, + struct aparams *, struct aparams *, int); int listen_nfds(struct file *); -int listen_pollfd(struct file *, struct pollfd *, int events); +int listen_pollfd(struct file *, struct pollfd *, int); int listen_revents(struct file *, struct pollfd *); void listen_close(struct file *); extern struct fileops listen_ops; diff --git a/usr.bin/aucat/sock.c b/usr.bin/aucat/sock.c index 06d32b69017..c1a3a2094a9 100644 --- a/usr.bin/aucat/sock.c +++ b/usr.bin/aucat/sock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.c,v 1.5 2008/11/16 17:08:32 ratchov Exp $ */ +/* $OpenBSD: sock.c,v 1.6 2008/11/16 18:34:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -260,7 +260,8 @@ struct aproc_ops wsock_ops = { * parameters */ struct sock * -sock_new(struct fileops *ops, int fd, char *name, int maxweight) +sock_new(struct fileops *ops, int fd, char *name, + struct aparams *wpar, struct aparams *rpar, int maxweight) { struct aproc *rproc, *wproc; struct sock *f; @@ -268,12 +269,14 @@ sock_new(struct fileops *ops, int fd, char *name, int maxweight) f = (struct sock *)pipe_new(ops, fd, name); f->pstate = SOCK_INIT; f->mode = 0; - if (dev_rec) { - f->wpar = dev_ipar; + if (dev_rec) { + f->templ_wpar = *wpar; + f->wpar = f->templ_wpar; f->mode |= AMSG_REC; } if (dev_play) { - f->rpar = dev_opar; + f->templ_rpar = *rpar; + f->rpar = f->templ_rpar; f->mode |= AMSG_PLAY; } f->xrun = AMSG_IGNORE; @@ -603,20 +606,26 @@ sock_setpar(struct sock *f) if (AMSG_ISSET(p->rchan) && (f->mode & AMSG_REC)) { if (p->rchan < 1) p->rchan = 1; - if (p->rchan > NCHAN_MAX - 1) - p->rchan = NCHAN_MAX - 1; - f->wpar.cmin = 0; - f->wpar.cmax = p->rchan - 1; - DPRINTF("sock_setpar: rchan -> %u\n", p->rchan); + if (p->rchan > NCHAN_MAX) + p->rchan = NCHAN_MAX; + f->wpar.cmin = f->templ_wpar.cmin; + f->wpar.cmax = f->templ_wpar.cmin + p->rchan - 1; + if (f->wpar.cmax > NCHAN_MAX - 1) + f->wpar.cmax = NCHAN_MAX - 1; + DPRINTF("sock_setpar: rchan -> %u:%u\n", + f->wpar.cmin, f->wpar.cmax); } if (AMSG_ISSET(p->pchan) && (f->mode & AMSG_PLAY)) { if (p->pchan < 1) p->pchan = 1; - if (p->pchan > NCHAN_MAX - 1) - p->pchan = NCHAN_MAX - 1; - f->rpar.cmin = 0; - f->rpar.cmax = p->pchan - 1; - DPRINTF("sock_setpar: pchan -> %u\n", p->pchan); + if (p->pchan > NCHAN_MAX) + p->pchan = NCHAN_MAX; + f->rpar.cmin = f->templ_rpar.cmin; + f->rpar.cmax = f->templ_wpar.cmin + p->pchan - 1; + if (f->rpar.cmax > NCHAN_MAX - 1) + f->rpar.cmax = NCHAN_MAX - 1; + DPRINTF("sock_setpar: pchan -> %u:%u\n", + f->rpar.cmin, f->rpar.cmax); } if (AMSG_ISSET(p->rate)) { if (p->rate < RATE_MIN) @@ -773,8 +782,10 @@ sock_execmsg(struct sock *f) m->cmd = AMSG_GETCAP; m->u.cap.rate = dev_rate; m->u.cap.rate_div = dev_rate_div; - m->u.cap.pchan = dev_opar.cmax - dev_opar.cmin + 1; - m->u.cap.rchan = dev_ipar.cmax - dev_ipar.cmin + 1; + m->u.cap.pchan = dev_mix ? + (f->templ_rpar.cmax - f->templ_rpar.cmin + 1) : 0; + m->u.cap.rchan = dev_sub ? + (f->templ_wpar.cmax - f->templ_wpar.cmin + 1) : 0; m->u.cap.bits = sizeof(short) * 8; m->u.cap.bps = sizeof(short); f->rstate = SOCK_RRET; @@ -970,4 +981,3 @@ sock_write(struct sock *f) } return 1; } - diff --git a/usr.bin/aucat/sock.h b/usr.bin/aucat/sock.h index 83b24dc2416..9b19d2dbd39 100644 --- a/usr.bin/aucat/sock.h +++ b/usr.bin/aucat/sock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sock.h,v 1.3 2008/11/16 16:30:22 ratchov Exp $ */ +/* $OpenBSD: sock.h,v 1.4 2008/11/16 18:34:56 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -52,9 +52,12 @@ struct sock { unsigned xrun; /* one of AMSG_IGNORE, ... */ int vol; /* requested volume */ int maxweight; /* max dynamic range */ + struct aparams templ_rpar; /* template for rpar */ + struct aparams templ_wpar; /* template for wpar */ }; -struct sock *sock_new(struct fileops *, int fd, char *, int); +struct sock *sock_new(struct fileops *, int fd, char *, + struct aparams *, struct aparams *, int); extern struct fileops sock_ops; #endif /* !defined(SOCK_H) */ |