Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/pad Pull up following revision(s) (requested by n...
details: https://anonhg.NetBSD.org/src/rev/bc4c848ed6e9
branches: netbsd-8
changeset: 433990:bc4c848ed6e9
user: snj <snj%NetBSD.org@localhost>
date: Sat Jun 10 06:05:47 2017 +0000
description:
Pull up following revision(s) (requested by nat in ticket #20):
sys/dev/pad/pad.c: revisions 1.33-1.35
sys/dev/pad/padvar.h: revision 1.9
Express BYTESTOSLEEP as an 64 bit integer.
Use BYTESTOSLEEP in expresson of BYTES_PER_SEC.
--
sc_bytes_count needs to be set in pad_audio_open not pad_open.
--
Simplification of rate limiter. It now works uni/multiprocessor.
--
pad blocksize 1024 -> 8192. Helps when sleeping in rate limiter.
diffstat:
sys/dev/pad/pad.c | 33 +++++++++++++--------------------
sys/dev/pad/padvar.h | 4 ++--
2 files changed, 15 insertions(+), 22 deletions(-)
diffs (105 lines):
diff -r 86440791db2c -r bc4c848ed6e9 sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Sat Jun 10 05:57:08 2017 +0000
+++ b/sys/dev/pad/pad.c Sat Jun 10 06:05:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $ */
+/* $NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32 2017/06/01 09:44:30 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.32.2.1 2017/06/10 06:05:47 snj Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -322,10 +322,6 @@
return EBUSY;
}
- getmicrotime(&sc->sc_last);
- sc->sc_bytes_count = 0;
- sc->sc_remainder = 0;
-
return 0;
}
@@ -345,8 +341,8 @@
}
#define PAD_BYTES_PER_SEC (44100 * sizeof(int16_t) * 2)
-#define TIMENEXTREAD (PAD_BLKSIZE * 1000000 / PAD_BYTES_PER_SEC)
-#define BYTESTOSLEEP (PAD_BLKSIZE)
+#define BYTESTOSLEEP (int64_t)(PAD_BLKSIZE)
+#define TIMENEXTREAD (int64_t)(BYTESTOSLEEP * 1000000 / PAD_BYTES_PER_SEC)
int
pad_read(dev_t dev, struct uio *uio, int flags)
@@ -374,10 +370,11 @@
nowusec = (now.tv_sec * 1000000) + now.tv_usec;
lastusec = (sc->sc_last.tv_sec * 1000000) +
sc->sc_last.tv_usec;
- if (lastusec + TIMENEXTREAD > nowusec &&
- sc->sc_bytes_count >= BYTESTOSLEEP) {
- sc->sc_remainder +=
- ((lastusec + TIMENEXTREAD) - nowusec);
+ if (lastusec + TIMENEXTREAD > nowusec) {
+ if (sc->sc_bytes_count >= BYTESTOSLEEP) {
+ sc->sc_remainder +=
+ ((lastusec + TIMENEXTREAD) - nowusec);
+ }
wait_ticks = (hz * sc->sc_remainder) / 1000000;
if (wait_ticks > 0) {
@@ -385,19 +382,14 @@
kpause("padwait", TRUE, wait_ticks,
&sc->sc_lock);
}
+ }
- sc->sc_bytes_count -= BYTESTOSLEEP;
- getmicrotime(&sc->sc_last);
- } else if (sc->sc_bytes_count >= BYTESTOSLEEP) {
+ if (sc->sc_bytes_count >= BYTESTOSLEEP)
sc->sc_bytes_count -= BYTESTOSLEEP;
- getmicrotime(&sc->sc_last);
- } else if (lastusec + TIMENEXTREAD <= nowusec) {
- getmicrotime(&sc->sc_last);
- sc->sc_remainder = 0;
- }
err = pad_get_block(sc, &pb, min(uio->uio_resid, PAD_BLKSIZE));
if (!err) {
+ getmicrotime(&sc->sc_last);
sc->sc_bytes_count += pb.pb_len;
mutex_exit(&sc->sc_lock);
err = uiomove(pb.pb_ptr, pb.pb_len, uio);
@@ -438,6 +430,7 @@
return EIO;
getmicrotime(&sc->sc_last);
+ sc->sc_bytes_count = 0;
sc->sc_remainder = 0;
return 0;
diff -r 86440791db2c -r bc4c848ed6e9 sys/dev/pad/padvar.h
--- a/sys/dev/pad/padvar.h Sat Jun 10 05:57:08 2017 +0000
+++ b/sys/dev/pad/padvar.h Sat Jun 10 06:05:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: padvar.h,v 1.8 2017/05/27 10:02:26 nat Exp $ */
+/* $NetBSD: padvar.h,v 1.8.2.1 2017/06/10 06:05:47 snj Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -44,7 +44,7 @@
struct audio_softc *sc_audiodev;
int sc_blksize;
-#define PAD_BLKSIZE 1024
+#define PAD_BLKSIZE 8192
#define PAD_BUFSIZE 65536
uint8_t sc_audiobuf[PAD_BUFSIZE];
uint32_t sc_buflen;
Home |
Main Index |
Thread Index |
Old Index