Fix long delay closing/syncing issues on mmaped buffer.

This commit is contained in:
Ariff Abdullah 2007-03-17 17:07:21 +00:00
parent ffd07a5307
commit 42a3b81e4e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=167663
2 changed files with 8 additions and 4 deletions

View file

@ -343,7 +343,7 @@ chn_wrfeed(struct pcm_channel *c)
})
#endif
if (c->flags & CHN_F_MAPPED)
if ((c->flags & CHN_F_MAPPED) && !(c->flags & CHN_F_CLOSING))
sndbuf_acquire(bs, NULL, sndbuf_getfree(bs));
amt = sndbuf_getfree(b);
@ -696,9 +696,9 @@ chn_resetbuf(struct pcm_channel *c)
int
chn_sync(struct pcm_channel *c, int threshold)
{
int ret, count, hcount, minflush, resid, residp;
struct snd_dbuf *b, *bs;
int syncdelay, blksz;
int ret, count, hcount, minflush, resid, residp, syncdelay, blksz;
u_int32_t cflag;
CHN_LOCKASSERT(c);
@ -769,6 +769,8 @@ chn_sync(struct pcm_channel *c, int threshold)
"minflush=%d resid=%d\n", __func__, c->timeout, count,
minflush, resid);
cflag = c->flags & CHN_F_CLOSING;
c->flags |= CHN_F_CLOSING;
while (count > 0 && (resid > 0 || minflush > 0)) {
ret = chn_sleep(c, "pcmsyn", c->timeout);
if (ret == ERESTART || ret == EINTR) {
@ -805,6 +807,8 @@ chn_sync(struct pcm_channel *c, int threshold)
residp = resid;
}
}
c->flags &= ~CHN_F_CLOSING;
c->flags |= cflag;
if (snd_verbose > 3)
printf("%s: timeout=%d count=%d hcount=%d resid=%d residp=%d "

View file

@ -226,7 +226,7 @@ feed_vchan(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b,
CHN_UNLOCK(ch);
continue;
}
if (ch->flags & CHN_F_MAPPED)
if ((ch->flags & CHN_F_MAPPED) && !(ch->flags & CHN_F_CLOSING))
sndbuf_acquire(ch->bufsoft, NULL,
sndbuf_getfree(ch->bufsoft));
if (rcnt == 0)