Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pad Fix previous.



details:   https://anonhg.NetBSD.org/src/rev/67714f6c5981
branches:  trunk
changeset: 376014:67714f6c5981
user:      nat <nat%NetBSD.org@localhost>
date:      Fri May 26 12:10:13 2023 +0000

description:
Fix previous.

The previous commit was misleading due to the flag names used.

The rationale for this change is that it is ok to return EAGAIN on first
read as playback has not started.  Then it shoud wait on every subsequent read.

This is what makes the high precsision throttling of pad(4), for which these
degree of fine-grained sleeps are not possible in userland.  This is a
requirement of users of pad(4) such as bta2dpd(8).

diffstat:

 sys/dev/pad/pad.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (43 lines):

diff -r 151f8dd100ab -r 67714f6c5981 sys/dev/pad/pad.c
--- a/sys/dev/pad/pad.c Fri May 26 10:44:59 2023 +0000
+++ b/sys/dev/pad/pad.c Fri May 26 12:10:13 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pad.c,v 1.83 2023/05/26 10:39:56 nat Exp $ */
+/* $NetBSD: pad.c,v 1.84 2023/05/26 12:10:13 nat 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.83 2023/05/26 10:39:56 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.84 2023/05/26 12:10:13 nat Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -324,7 +324,7 @@ pad_get_block(struct pad_softc *sc, pad_
        KASSERT(maxblksize > 0);
        KASSERT(mutex_owned(&sc->sc_intr_lock));
 
-       if (sc->sc_buflen == 0 && dowait)
+       if (sc->sc_buflen == 0 && !dowait)
                return EAGAIN;
 
        while (sc->sc_buflen == 0) {
@@ -515,13 +515,13 @@ pad_read(struct pad_softc *sc, off_t *of
        int err, first;
 
        err = 0;
-       first = 1;
+       first = 0;
        DPRINTF("%s: resid=%zu\n", __func__, uio->uio_resid);
        while (uio->uio_resid > 0) {
                mutex_enter(&sc->sc_intr_lock);
                err = pad_get_block(sc, &pb, MIN(uio->uio_resid, INT_MAX), first);
                mutex_exit(&sc->sc_intr_lock);
-               first = 0;
+               first = 1;
                if (err == EAGAIN) {
                        err = 0;
                        break;



Home | Main Index | Thread Index | Old Index