--- /usr/cvs/RELENG_6.orig/src/sys/dev/sound/pcm/buffer.c Sat Dec 31 03:55:54 2005 +++ buffer.c Sun Feb 26 16:46:08 2006 @@ -28,7 +28,7 @@ #include "feeder_if.h" -SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/buffer.c,v 1.25.2.1 2005/12/30 19:55:54 netchild Exp $"); +SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pcm/buffer.c,v 1.26 2005/07/31 16:16:22 netchild Exp $"); struct snd_dbuf * sndbuf_create(device_t dev, char *drv, char *desc, struct pcm_channel *channel) @@ -545,15 +545,28 @@ int sndbuf_feed(struct snd_dbuf *from, struct snd_dbuf *to, struct pcm_channel *channel, struct pcm_feeder *feeder, unsigned int count) { + unsigned int cnt, feedcount = 0; + KASSERT(count > 0, ("can't feed 0 bytes")); if (sndbuf_getfree(to) < count) return EINVAL; - count = FEEDER_FEED(feeder, channel, to->tmpbuf, count, from); - if (count) - sndbuf_acquire(to, to->tmpbuf, count); - /* the root feeder has called sndbuf_dispose(from, , bytes fetched) */ + do { + cnt = FEEDER_FEED(feeder, channel, to->tmpbuf, count, from); + if (cnt) + sndbuf_acquire(to, to->tmpbuf, cnt); + /* the root feeder has called sndbuf_dispose(from, , bytes fetched) */ + count -= cnt; + if (count) { + if (cnt) + feedcount++; + else if (feedcount) + feedcount--; + } + } while (count && cnt); + + channel->feedcount += feedcount; return 0; }