summaryrefslogtreecommitdiffstats
path: root/sys/dev/sound/pcm/channel.c
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>2001-10-24 12:33:21 +0000
committercg <cg@FreeBSD.org>2001-10-24 12:33:21 +0000
commit92b427043693ed62f8a448331588c3e9d32c927c (patch)
treece7b658fe1034d0c1762dd43af8797529bcffa79 /sys/dev/sound/pcm/channel.c
parentb58e003d32f2842ee55360072b73483b6714eecd (diff)
downloadFreeBSD-src-92b427043693ed62f8a448331588c3e9d32c927c.zip
FreeBSD-src-92b427043693ed62f8a448331588c3e9d32c927c.tar.gz
improve recording behaviour
Diffstat (limited to 'sys/dev/sound/pcm/channel.c')
-rw-r--r--sys/dev/sound/pcm/channel.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index c21076c..adf3fb9 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -334,8 +334,10 @@ chn_rdfeed(struct pcm_channel *c)
})
amt = sndbuf_getready(b);
- if (sndbuf_getfree(bs) < amt)
+ if (sndbuf_getfree(bs) < amt) {
c->xruns++;
+ amt = sndbuf_getfree(bs);
+ }
ret = (amt > 0)? sndbuf_feed(b, bs, c, c->feeder, amt) : 0;
amt = sndbuf_getready(b);
@@ -400,14 +402,14 @@ chn_read(struct pcm_channel *c, struct uio *buf)
ret = 0;
count = hz;
while (!ret && (buf->uio_resid > 0) && (count > 0)) {
- sz = MIN(buf->uio_resid, sndbuf_getblksz(bs));
+ sz = MIN(buf->uio_resid, sndbuf_getready(bs));
- if (sz <= sndbuf_getready(bs)) {
+ if (sz > 0) {
ret = sndbuf_uiomove(bs, buf, sz);
} else {
- if (c->flags & CHN_F_NBIO)
+ if (c->flags & CHN_F_NBIO) {
ret = EWOULDBLOCK;
- else {
+ } else {
timeout = (hz * sndbuf_getblksz(bs)) / (sndbuf_getspd(bs) * sndbuf_getbps(bs));
if (timeout < 1)
timeout = 1;
@@ -415,7 +417,10 @@ chn_read(struct pcm_channel *c, struct uio *buf)
if (ret == EWOULDBLOCK) {
count -= timeout;
ret = 0;
+ } else {
+ count = hz;
}
+
}
}
}
OpenPOWER on IntegriCloud