summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Grant <cg@FreeBSD.org>2000-08-20 00:25:05 +0000
committerCameron Grant <cg@FreeBSD.org>2000-08-20 00:25:05 +0000
commit798220c4a1ca2da0ef47d69a5a9c7ff660c9a1a1 (patch)
tree841439d8b21e0eb78b81b55cb72c24a08dd1ee87
parent7bde978681fbd6a6b617e54f271f79ef5a85739e (diff)
Notes
-rw-r--r--sys/dev/sound/pcm/channel.c21
-rw-r--r--sys/dev/sound/pcm/datatypes.h3
2 files changed, 21 insertions, 3 deletions
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index cb2c9e5a21f8..cd4090389752 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -186,6 +186,11 @@ chn_dmaupdate(pcm_channel *c)
DEB (int b_rl=b->rl; int b_fl=b->fl; int b_rp=b->rp; int b_fp=b->fp);
hwptr = chn_getptr(c);
+ delta = (b->bufsize + hwptr - b->hp) % b->bufsize;
+ if (delta >= ((b->bufsize * 3) / 4)) {
+ if (!(c->flags & (CHN_F_CLOSING | CHN_F_ABORTING)))
+ device_printf(c->parent->dev, "hwptr went backwards %d -> %d\n", b->hp, hwptr);
+ }
if (c->direction == PCMDIR_PLAY) {
delta = (b->bufsize + hwptr - b->rp) % b->bufsize;
b->rp = hwptr;
@@ -204,6 +209,7 @@ chn_dmaupdate(pcm_channel *c)
DEB(printf("OUCH!(%d) fl %d(%d) delta %d bufsize %d hwptr %d fp %d(%d)\n", chn_updatecount++, b->fl, b_fl, delta, b->bufsize, hwptr, b->fp, b_fp));
}
}
+ b->hp = hwptr;
b->total += delta;
}
@@ -234,7 +240,7 @@ chn_checkunderflow(pcm_channel *c)
b->fl = b->bufsize - b->rl;
b->underflow = 0;
} else {
- /* chn_dmaupdate(c); */
+ chn_dmaupdate(c);
}
}
@@ -547,8 +553,19 @@ static int
chn_rddump(pcm_channel *c, int cnt)
{
snd_dbuf *b = &c->buffer;
+ int maxover, ss;
- printf("overrun, dumping %d bytes\n", cnt);
+ ss = 1;
+ ss <<= (b->fmt & AFMT_STEREO)? 1 : 0;
+ ss <<= (b->fmt & AFMT_16BIT)? 1 : 0;
+ maxover = c->speed * ss;
+
+ b->overrun += cnt;
+ if (b->overrun > maxover) {
+ device_printf(c->parent->dev, "record overrun, dumping %d bytes\n",
+ b->overrun);
+ b->overrun = 0;
+ }
b->rl -= cnt;
b->fl += cnt;
b->rp = (b->rp + cnt) % b->bufsize;
diff --git a/sys/dev/sound/pcm/datatypes.h b/sys/dev/sound/pcm/datatypes.h
index 31df62be1d79..716c21b7c211 100644
--- a/sys/dev/sound/pcm/datatypes.h
+++ b/sys/dev/sound/pcm/datatypes.h
@@ -63,11 +63,12 @@ struct _snd_dbuf {
volatile int dl; /* transfer size */
volatile int rp, fp; /* pointers to the ready and free area */
volatile int rl, fl; /* lenght of ready and free areas. */
+ volatile int hp;
volatile u_int32_t int_count, prev_int_count;
volatile u_int32_t total, prev_total;
int chan, dir; /* dma channel */
int fmt, blksz, blkcnt;
- int underflow;
+ int underflow, overrun;
bus_dmamap_t dmamap;
struct selinfo sel;
};