summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJacob Meuser <jakemsr@cvs.openbsd.org>2007-07-17 10:35:11 +0000
committerJacob Meuser <jakemsr@cvs.openbsd.org>2007-07-17 10:35:11 +0000
commit9eab1228a6a13e7e14b58bca5b08ed3ce80d4118 (patch)
tree7e72fc8ce8fd703a186cf2b0aaa94b725a2711c8 /sys
parent4efdde5a1d2ee922bbc505542edf36562116656e (diff)
- the data in the read buffer, that was put there by the hardware,
may not be the same sample size as what userland is to receive. account for the discrepency between the sample sizes when comparing how much to copy out with what userland expects. - only copy out the part of the buffer that is in the format userland expects. emu(4) can now record with all encodings it claims to be able to. that is, dd if=/dev/audio of=foo does as audio(4) says (monaural mu-law) and does it correctly. AFAIKS, the only other driver that sets a read factor is uaudio(4), and that depends on what the hardware supports. tested on i386, amd64 and sgi with 3 different emu(4) cards
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/audio.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/audio.c b/sys/dev/audio.c
index 64e28fa0137..40e4112abd7 100644
--- a/sys/dev/audio.c
+++ b/sys/dev/audio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: audio.c,v 1.64 2007/07/14 02:31:33 jakemsr Exp $ */
+/* $OpenBSD: audio.c,v 1.65 2007/07/17 10:35:10 jakemsr Exp $ */
/* $NetBSD: audio.c,v 1.119 1999/11/09 16:50:47 augustss Exp $ */
/*
@@ -1237,13 +1237,14 @@ audio_read(dev_t dev, struct uio *uio, int ioflag)
if (n < cc)
cc = n; /* don't read beyond end of buffer */
- if (uio->uio_resid < cc)
- cc = uio->uio_resid; /* and no more than we want */
+ /* and no more than we want */
+ if (uio->uio_resid < cc / sc->sc_rparams.factor)
+ cc = uio->uio_resid * sc->sc_rparams.factor;
if (sc->sc_rparams.sw_code)
sc->sc_rparams.sw_code(sc->hw_hdl, outp, cc);
DPRINTFN(1,("audio_read: outp=%p, cc=%d\n", outp, cc));
- error = uiomove(outp, cc, uio);
+ error = uiomove(outp, cc / sc->sc_rparams.factor, uio);
used -= cc;
outp += cc;
if (outp >= cb->end)