1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

more mmap fixes

This commit is contained in:
Cameron Grant 2000-04-17 17:06:47 +00:00
parent 674c45bd04
commit 8ae4c159aa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=59324
3 changed files with 30 additions and 35 deletions

View File

@ -336,7 +336,7 @@ static void
chn_wrintr(pcm_channel *c)
{
snd_dbuf *b = &c->buffer;
int start, dl, l;
int start, l;
if (b->underflow && !(c->flags & CHN_F_MAPPED)) {
/* printf("underflow return\n");
@ -485,7 +485,7 @@ chn_write(pcm_channel *c, struct uio *buf)
/* Start playing if not yet. */
if ((bs->rl || b->rl) && !b->dl) {
chn_wrintr(c);
chn_intr(c);
}
if (c->flags & CHN_F_NBIO) {
@ -501,7 +501,7 @@ chn_write(pcm_channel *c, struct uio *buf)
while (chn_wrfeed2nd(c, buf) > 0);
/* Start playing if necessary. */
if ((bs->rl || b->rl) && !b->dl) chn_wrintr(c);
if ((bs->rl || b->rl) && !b->dl) chn_intr(c);
/* Have we finished to feed the secondary buffer? */
if (buf->uio_resid == 0)
@ -738,7 +738,7 @@ chn_read(pcm_channel *c, struct uio *buf)
while (chn_rdfeed2nd(c, buf) > 0);
/* Start capturing if not yet. */
if ((!bs->rl || !b->rl) && !b->dl) chn_rdintr(c);
if ((!bs->rl || !b->rl) && !b->dl) chn_intr(c);
if (!(c->flags & CHN_F_NBIO)) {
/* Wait until all samples are captured. */
@ -748,7 +748,7 @@ chn_read(pcm_channel *c, struct uio *buf)
while (chn_rdfeed2nd(c, buf) > 0);
/* Start capturing if necessary. */
if ((!bs->rl || !b->rl) && !b->dl) chn_rdintr(c);
if ((!bs->rl || !b->rl) && !b->dl) chn_intr(c);
/* Have we finished to feed the uio? */
if (buf->uio_resid == 0)
@ -775,7 +775,12 @@ chn_read(pcm_channel *c, struct uio *buf)
void
chn_intr(pcm_channel *c)
{
if (c->direction == PCMDIR_PLAY) chn_wrintr(c); else chn_rdintr(c);
if (c->flags & CHN_F_INIT)
chn_reinit(c);
if (c->direction == PCMDIR_PLAY)
chn_wrintr(c);
else
chn_rdintr(c);
}
static void
@ -949,14 +954,14 @@ chn_poll(pcm_channel *c, int ev, struct proc *p)
if (c->direction == PCMDIR_PLAY) {
/* Fill up the DMA buffer. */
chn_checkunderflow(c);
while(chn_wrfeed(c) > 0);
if (!b->dl) chn_wrintr(c);
while (chn_wrfeed(c) > 0);
} else {
/* Suck up the DMA buffer. */
chn_dmaupdate(c);
while(chn_rdfeed(c) > 0);
if (!b->dl) chn_rdintr(c);
while (chn_rdfeed(c) > 0);
}
if (!b->dl)
chn_intr(c);
}
ret = 0;
if (chn_polltrigger(c) && chn_pollreset(c))
@ -1034,7 +1039,7 @@ chn_flush(pcm_channel *c)
}
int
chn_reset(pcm_channel *c)
chn_reset(pcm_channel *c, u_int32_t fmt)
{
int r;
@ -1043,9 +1048,11 @@ chn_reset(pcm_channel *c)
r = chn_setblocksize(c, CHN_2NDBUFBLKNUM, CHN_2NDBUFBLKSIZE);
if (r)
return r;
c->format = AFMT_U8;
c->speed = 8000;
c->volume = (100 << 8) | 100;
if (fmt) {
c->format = fmt;
c->speed = DSP_DEFAULT_SPEED;
c->volume = (100 << 8) | 100;
}
chn_resetbuf(c);
c->flags |= CHN_F_INIT;
return 0;
@ -1142,6 +1149,8 @@ chn_setblocksize(pcm_channel *c, int blkcnt, int blksz)
snd_dbuf *bs = &c->buffer2nd;
int s, bufsz;
if (c->fragments == blkcnt && c->blocksize2nd == blksz)
return 0;
if (c->flags & CHN_F_MAPPED) {
DEB(printf("chn_setblocksize: can't work on mapped channel"));
return EINVAL;

View File

@ -35,7 +35,7 @@ int chn_poll(pcm_channel *c, int ev, struct proc *p);
int chn_init(pcm_channel *c, void *devinfo, int dir);
int chn_setdir(pcm_channel *c, int dir);
int chn_reset(pcm_channel *c);
int chn_reset(pcm_channel *c, u_int32_t fmt);
int chn_setvolume(pcm_channel *c, int left, int right);
int chn_setspeed(pcm_channel *c, int speed);
int chn_setformat(pcm_channel *c, u_int32_t fmt);

View File

@ -124,22 +124,12 @@ dsp_open(snddev_info *d, int chan, int oflags, int devtype)
}
if (rdch && (oflags & FREAD)) {
chn_reset(rdch);
chn_reset(rdch, fmt);
if (oflags & O_NONBLOCK) rdch->flags |= CHN_F_NBIO;
if (fmt) {
rdch->volume = (100 << 8) | 100;
rdch->format = fmt;
rdch->speed = DSP_DEFAULT_SPEED;
}
}
if (wrch && (oflags & FWRITE)) {
chn_reset(wrch);
chn_reset(wrch, fmt);
if (oflags & O_NONBLOCK) wrch->flags |= CHN_F_NBIO;
if (fmt) {
wrch->volume = (100 << 8) | 100;
wrch->format = fmt;
wrch->speed = DSP_DEFAULT_SPEED;
}
}
return 0;
}
@ -158,12 +148,12 @@ dsp_close(snddev_info *d, int chan, int devtype)
if (rdch) {
chn_abort(rdch);
rdch->flags &= ~(CHN_F_BUSY | CHN_F_RUNNING | CHN_F_MAPPED);
chn_reset(rdch);
chn_reset(rdch, 0);
}
if (wrch) {
chn_flush(wrch);
wrch->flags &= ~(CHN_F_BUSY | CHN_F_RUNNING | CHN_F_MAPPED);
chn_reset(wrch);
chn_reset(wrch, 0);
}
d->aplay[chan] = NULL;
d->arec[chan] = NULL;
@ -181,10 +171,8 @@ dsp_read(snddev_info *d, int chan, struct uio *buf, int flag)
KASSERT(rdch, ("dsp_read: nonexistant channel"));
KASSERT(rdch->flags & CHN_F_BUSY, ("dsp_read: nonbusy channel"));
if (rdch->flags & CHN_F_MAPPED) return EINVAL;
if (!(rdch->flags & CHN_F_RUNNING)) {
if (!(rdch->flags & CHN_F_RUNNING))
rdch->flags |= CHN_F_RUNNING;
chn_reinit(rdch);
}
return chn_read(rdch, buf);
}
@ -199,10 +187,8 @@ dsp_write(snddev_info *d, int chan, struct uio *buf, int flag)
KASSERT(wrch, ("dsp_write: nonexistant channel"));
KASSERT(wrch->flags & CHN_F_BUSY, ("dsp_write: nonbusy channel"));
if (wrch->flags & CHN_F_MAPPED) return EINVAL;
if (!(wrch->flags & CHN_F_RUNNING)) {
if (!(wrch->flags & CHN_F_RUNNING))
wrch->flags |= CHN_F_RUNNING;
chn_reinit(wrch);
}
return chn_write(wrch, buf);
}