Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F170864099
D57833.id181298.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D57833.id181298.diff
View Options
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -260,7 +260,7 @@
u_int32_t chn_start(struct pcm_channel *c, int force);
int chn_sync(struct pcm_channel *c, int threshold);
int chn_flush(struct pcm_channel *c);
-int chn_polltrigger(struct pcm_channel *c);
+int chn_polltrigger(struct pcm_channel *c, u_int64_t ref_total);
int chn_poll(struct pcm_channel *c, int ev, struct thread *td);
char *chn_mkname(char *buf, size_t len, struct pcm_channel *c);
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -270,11 +270,15 @@
/**
* @brief Determine channel is ready for I/O
*
+ * @param ref_total for mmaped channels, the previous byte counter
+ * * snapshot from which to compute the delta to
+ * * bufsoft->total; ignored for non-mmaped channels.
+ *
* @retval 1 = ready for I/O
* @retval 0 = not ready for I/O
*/
int
-chn_polltrigger(struct pcm_channel *c)
+chn_polltrigger(struct pcm_channel *c, u_int64_t ref_total)
{
struct snd_dbuf *bs = c->bufsoft;
u_int delta;
@@ -282,10 +286,10 @@
CHN_LOCKASSERT(c);
if (c->flags & CHN_F_MMAP) {
- if (bs->prev_total < c->lw)
+ if (ref_total < c->lw)
delta = c->lw;
else
- delta = bs->total - bs->prev_total;
+ delta = bs->total - ref_total;
} else {
if (c->direction == PCMDIR_PLAY)
delta = sndbuf_getfree(bs);
@@ -316,7 +320,7 @@
if (CHN_EMPTY(c, children.busy)) {
KNOTE_LOCKED(&bs->sel.si_note, 0);
- if (SEL_WAITING(&bs->sel) && chn_polltrigger(c))
+ if (SEL_WAITING(&bs->sel) && chn_polltrigger(c, bs->prev_total))
selwakeuppri(&bs->sel, PRIBIO);
CHN_BROADCAST(&c->intr_cv);
} else {
@@ -830,7 +834,7 @@
}
ret = 0;
- if (chn_polltrigger(c)) {
+ if (chn_polltrigger(c, bs->prev_total)) {
chn_pollreset(c);
ret = ev;
} else
diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c
--- a/sys/dev/sound/pcm/dsp.c
+++ b/sys/dev/sound/pcm/dsp.c
@@ -3010,7 +3010,13 @@
return (1);
}
kn->kn_data = 0;
- if (chn_polltrigger(ch)) {
+ /*
+ * For mmaped channels pass the knote's own reference point so the
+ * low watermark is tracked per-knote. Non-mmaped channels ignore
+ * the reference and fire based on the current amount of ready/free
+ * data in the buffer, so all knotes see the same live state.
+ */
+ if (chn_polltrigger(ch, (u_int64_t)kn->kn_sdata)) {
if (kn->kn_filter == EVFILT_READ) {
kn->kn_data = sndbuf_getready(ch->bufsoft);
if (ch->flags & CHN_F_MMAP)
@@ -3025,6 +3031,7 @@
kn->kn_kevent.ext[0] = sndbuf_getready(ch->bufsoft) / ch->bufsoft->align;
}
kn->kn_kevent.ext[1] = ch->xruns;
+ kn->kn_sdata = ch->bufsoft->total;
}
return (kn->kn_data > 0);
@@ -3070,6 +3077,11 @@
knlist_add(&ch->bufsoft->sel.si_note, kn, 1);
CHN_UNLOCK(ch);
kn->kn_hook = ch;
+ /*
+ * Start tracking from the current position so the first event
+ * fires after c->lw additional bytes have been transferred.
+ */
+ kn->kn_sdata = ch->bufsoft->prev_total;
} else
err = EINVAL;
PCM_GIANT_LEAVE(d);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 8, 3:05 AM (22 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38414275
Default Alt Text
D57833.id181298.diff (3 KB)
Attached To
Mode
D57833: sound: track kqueue low watermark per-knote for mmaped channels
Attached
Detach File
Event Timeline
Log In to Comment