diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-20 10:10:02 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-11-20 10:10:02 +0000 |
commit | 4db591a8e135086c5c6fb13984c9914f9a1c8375 (patch) | |
tree | e7ed18d0b81b2152d08e23a11120cabd43903e4c | |
parent | 525435551d990dca513d5d81e57065bf55bc5b58 (diff) |
take into account socket parameters into calculation of device
parameters; without this change aucat uses the device default
parameters and they are not necessarily usable for multi-stream
mode.
-rw-r--r-- | usr.bin/aucat/aparams.c | 18 | ||||
-rw-r--r-- | usr.bin/aucat/aparams.h | 3 | ||||
-rw-r--r-- | usr.bin/aucat/aucat.c | 40 |
3 files changed, 35 insertions, 26 deletions
diff --git a/usr.bin/aucat/aparams.c b/usr.bin/aucat/aparams.c index 130561128f4..c0fc85ae308 100644 --- a/usr.bin/aucat/aparams.c +++ b/usr.bin/aucat/aparams.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aparams.c,v 1.4 2008/11/10 23:25:37 ratchov Exp $ */ +/* $OpenBSD: aparams.c,v 1.5 2008/11/20 10:10:01 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -243,6 +243,21 @@ aparams_subset(struct aparams *subset, struct aparams *set) } /* + * grow channels range and sample rate of ``set'' in order ``subset'' to + * become an actual subset of it. + */ +void +aparams_grow(struct aparams *set, struct aparams *subset) +{ + if (set->cmin > subset->cmin) + set->cmin = subset->cmin; + if (set->cmax < subset->cmax) + set->cmax = subset->cmax; + if (set->rate < subset->rate) + set->rate = subset->rate; +} + +/* * Return true if rates are the same */ int @@ -271,4 +286,3 @@ aparams_copyenc(struct aparams *dst, struct aparams *src) dst->bits = src->bits; dst->bps = src->bps; } - diff --git a/usr.bin/aucat/aparams.h b/usr.bin/aucat/aparams.h index 79d2b50e11d..d89aaaf2637 100644 --- a/usr.bin/aucat/aparams.h +++ b/usr.bin/aucat/aparams.h @@ -1,4 +1,4 @@ -/* $OpenBSD: aparams.h,v 1.4 2008/11/10 23:25:37 ratchov Exp $ */ +/* $OpenBSD: aparams.h,v 1.5 2008/11/20 10:10:01 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -81,6 +81,7 @@ int aparams_eqrate(struct aparams *, struct aparams *); int aparams_eqenc(struct aparams *, struct aparams *); int aparams_eq(struct aparams *, struct aparams *); int aparams_subset(struct aparams *, struct aparams *); +void aparams_grow(struct aparams *, struct aparams *); unsigned aparams_bpf(struct aparams *); int aparams_strtoenc(struct aparams *, char *); int aparams_enctostr(struct aparams *, char *); diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c index c5490d72411..d71371f7fae 100644 --- a/usr.bin/aucat/aucat.c +++ b/usr.bin/aucat/aucat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aucat.c,v 1.45 2008/11/17 09:40:09 jmc Exp $ */ +/* $OpenBSD: aucat.c,v 1.46 2008/11/20 10:10:01 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org> * @@ -447,38 +447,32 @@ main(int argc, char **argv) mode |= MODE_REC; } - if (!u_flag && !l_flag) { + /* + * if there are no sockets paths provided use the default + */ + if (l_flag && SLIST_EMPTY(&sfiles)) { + farg_add(&sfiles, &dopar, &dipar, + MIDI_MAXCTL, HDR_RAW, XRUN_IGNORE, DEFAULT_SOCKET); + } + + if (!u_flag) { /* * Calculate "best" device parameters. Iterate over all * inputs and outputs and find the maximum sample rate * and channel number. */ - aparams_init(&dipar, NCHAN_MAX - 1, 0, RATE_MAX); + aparams_init(&dipar, NCHAN_MAX - 1, 0, RATE_MIN); aparams_init(&dopar, NCHAN_MAX - 1, 0, RATE_MIN); SLIST_FOREACH(fa, &ifiles, entry) { - if (dopar.cmin > fa->ipar.cmin) - dopar.cmin = fa->ipar.cmin; - if (dopar.cmax < fa->ipar.cmax) - dopar.cmax = fa->ipar.cmax; - if (dopar.rate < fa->ipar.rate) - dopar.rate = fa->ipar.rate; + aparams_grow(&dopar, &fa->ipar); } SLIST_FOREACH(fa, &ofiles, entry) { - if (dipar.cmin > fa->opar.cmin) - dipar.cmin = fa->opar.cmin; - if (dipar.cmax < fa->opar.cmax) - dipar.cmax = fa->opar.cmax; - if (dipar.rate > fa->opar.rate) - dipar.rate = fa->opar.rate; + aparams_grow(&dipar, &fa->opar); + } + SLIST_FOREACH(fa, &sfiles, entry) { + aparams_grow(&dopar, &fa->ipar); + aparams_grow(&dipar, &fa->opar); } - } - - /* - * if there are no sockets paths provided use the default - */ - if (l_flag && SLIST_EMPTY(&sfiles)) { - farg_add(&sfiles, &dopar, &dipar, - MIDI_MAXCTL, HDR_RAW, XRUN_IGNORE, DEFAULT_SOCKET); } quit_flag = 0; |