warn if hwptr goes backwards

This commit is contained in:
cg 2000-08-09 00:42:00 +00:00
parent 7042946f94
commit 84560963e5
2 changed files with 8 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -63,6 +63,7 @@ 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 */