summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/safile.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/aucat/safile.c')
-rw-r--r--usr.bin/aucat/safile.c105
1 files changed, 6 insertions, 99 deletions
diff --git a/usr.bin/aucat/safile.c b/usr.bin/aucat/safile.c
index 0f4d2673e2a..775d451a6aa 100644
--- a/usr.bin/aucat/safile.c
+++ b/usr.bin/aucat/safile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: safile.c,v 1.4 2008/11/08 10:40:52 ratchov Exp $ */
+/* $OpenBSD: safile.c,v 1.5 2008/12/07 17:10:41 ratchov Exp $ */
/*
* Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
*
@@ -61,101 +61,6 @@ struct fileops safile_ops = {
safile_revents
};
-/*
- * list of (rate, block-size) pairs ordered by frequency preference and
- * then by block size preference (except for jumbo block sizes that are
- * less prefered than anything else).
- */
-struct blkdesc {
- unsigned rate; /* sample rate */
- unsigned round; /* usable block sizes */
-} blkdesc[] = {
- { 44100, 882 },
- { 44100, 840 },
- { 44100, 441 },
- { 44100, 420 },
- { 44100, 1764 },
- { 44100, 1680 },
- { 48000, 960 },
- { 48000, 768 },
- { 48000, 480 },
- { 48000, 384 },
- { 48000, 1920 },
- { 48000, 1536 },
- { 32000, 640 },
- { 32000, 512 },
- { 32000, 320 },
- { 32000, 256 },
- { 32000, 1280 },
- { 32000, 1024 },
- { 44100, 2940 },
- { 48000, 2976 },
- { 32000, 3200 },
- { 8000, 320 },
- { 8000, 256 },
- { 0, 0 }
-};
-
-
-int
-safile_trypar(struct sio_hdl *hdl, struct sio_par *par, int blkio)
-{
- struct blkdesc *d;
- struct sio_par np;
- unsigned rate = par->rate;
- unsigned round = par->round;
-
- if (!blkio) {
- DPRINTF("safile_trypar: not setting block size\n");
- if (!sio_setpar(hdl, par))
- return 0;
- if (!sio_getpar(hdl, par))
- return 0;
- return 1;
- }
-
- /*
- * find the rate we want to use
- */
- for (d = blkdesc;; d++) {
- if (d->rate == 0) {
- d = blkdesc;
- break;
- }
- if (d->rate == rate)
- break;
- }
-
- /*
- * find the first matching entry, (the blkdesc array is)
- * sorted by order of preference)
- */
- for (;; d++) {
- if (d->rate == 0)
- break;
- if (d->round > round)
- continue;
- par->rate = d->rate;
- par->round = d->round;
- if (!sio_setpar(hdl, par))
- return 0;
- if (!sio_getpar(hdl, &np))
- return 0;
- if (np.rate == d->rate && np.round == d->round) {
- *par = np;
- if (d->round >= d->rate / 15)
- fprintf(stderr,
- "Warning: using jumbo block size, "
- "try to use another sample rate.\n");
- return 1;
- }
- DPRINTF("safile_trypar: %uHz/%ufr failed, got %uHz/%ufr\n",
- d->rate, d->round, np.rate, np.round);
- }
- fprintf(stderr, "Couldn't set block size to <%u frames.\n", round);
- return 0;
-}
-
void
safile_cb(void *addr, int delta)
{
@@ -180,7 +85,7 @@ safile_cb(void *addr, int delta)
struct safile *
safile_new(struct fileops *ops, char *path,
struct aparams *ipar, struct aparams *opar,
- unsigned *bufsz, unsigned *round, int blkio)
+ unsigned *bufsz, unsigned *round)
{
struct sio_par par;
struct sio_hdl *hdl;
@@ -222,8 +127,10 @@ safile_new(struct fileops *ops, char *path,
par.pchan = opar->cmax - opar->cmin + 1;
par.bufsz = *bufsz;
par.round = *round;
- if (!safile_trypar(hdl, &par, blkio))
- exit(1);
+ if (!sio_setpar(hdl, &par))
+ return 0;
+ if (!sio_getpar(hdl, &par))
+ return 0;
if (ipar) {
ipar->bits = par.bits;
ipar->bps = par.bps;