From nobody Tue Jun 30 06:24:33 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gqCmK4KYnz6jcQh for ; Tue, 30 Jun 2026 06:24:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gqCmK1VcYz3FsJ for ; Tue, 30 Jun 2026 06:24:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782800673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qVr6CPXos1pgEjzkaig/FDiuSOSm0UUnnHzDCk5bNhw=; b=LcW/2bdYSig2U2Vn3Ilbw+tF2NNWw38STPrj8sodag+w3MHMwisHXOrbJCBG0fps4npUeO EdKy1thiP7+lR1Ly/7ON0pWA7kh3uyAR4RnHTVqkmUSHSKuulfArIt72IV6rkA4dbKYyY0 K45IykVLb8jJCMY1pUbhZinnRUVZ7Wip4ldaxi4QmtxM6t9hS/zUe8Zj+pWWd/tyJ8J2Vh fC4ROdNcWhkS6G8jB8z+ksPIhuPZeL7PtQoB8DKqiual5BvlsxoWp0nmhFTmz0+u7F7t4B fc/L2Wbsm7TeAiPjksq997jtF4Y3mZp/weMvPByhOQKlEOPGsmfyj9IjsEl9eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782800673; a=rsa-sha256; cv=none; b=In+1s1tcx55aUBHdyrhhGJlxV0mCOfKC+Kwp5wzRbzfQiGTPKp6unrRsQZDLUwuAyabs4S ZNf7bC4M2p0S1SRDfAWn/DFMKAFM90YkUZfjWhrkLwkM9JxQAC/nP4alusYNTYT5EzBYIC QbysIyoHTeda0FcFuxwrcg1EaCjQ7sIGbre3JY0tVTAT2xEagE53nx2MNSc+1uN598Cnen MzwOihkxljPB9Exvv+aOf8EwuNKAaugvUtomJJfRzFKWwIFRsuudYfehukFLgz4dQn9ya8 ofJbhyeaR+0E30OkDYDcu26WxXBfb+EsuFgXMa+amKo1RcxdOy1uu2ozJig1tw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782800673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qVr6CPXos1pgEjzkaig/FDiuSOSm0UUnnHzDCk5bNhw=; b=fOiWejIO2lAkdfoQQ62G6EqQWUF24PC4bwQClt+CCkMdW4D3W/wuvxNQ5bY1o9akvBidcZ Cq4PddLaOKkDcN1OG5p1215YRDx1K2jdYYIADTUcorbHw6GoJdMnHHfuDuZoC7kPi2qvFD UH+zFybY/GZRLL0hKMlBR6KnZgH1gbq7f12Z6dEHCF4sy0203HRalLxcSVIYzLg4SOqY1p aIyfUC13AfSjo54wc5GXK3zFVhZE0JI3eOnNp+jtET/xXcUP+3UB8676Xo5YHki/OBkP7J C1cCEmzlbDFgadGeAKjsMoohaPH8iEs8SqHXLUDMa6zlN68wh3Thf7nbNYk0HQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gqCmK09cFzYND for ; Tue, 30 Jun 2026 06:24:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 20d1f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 30 Jun 2026 06:24:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Goran=?utf-8?Q? Meki=C4=87?= From: Christos Margiolis Subject: git: 5347284ba90f - stable/15 - sound: Include more information in kevent returned from the kernel List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 5347284ba90fd52eeb5d23e50673f23a3b77c8ad Auto-Submitted: auto-generated Date: Tue, 30 Jun 2026 06:24:33 +0000 Message-Id: <6a436121.20d1f.50ec7296@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=5347284ba90fd52eeb5d23e50673f23a3b77c8ad commit 5347284ba90fd52eeb5d23e50673f23a3b77c8ad Author: Goran Mekić AuthorDate: 2026-06-17 10:35:07 +0000 Commit: Christos Margiolis CommitDate: 2026-06-30 06:23:56 +0000 sound: Include more information in kevent returned from the kernel Reviewed by: christos Differential Revision: https://reviews.freebsd.org/D57362 (cherry picked from commit fe13f70b95a762e19c38d1152eac6312d8578f84) --- share/man/man4/pcm.4 | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ sys/dev/sound/pcm/dsp.c | 14 +++++++-- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/share/man/man4/pcm.4 b/share/man/man4/pcm.4 index 7a0059f43f73..1aebff562d8f 100644 --- a/share/man/man4/pcm.4 +++ b/share/man/man4/pcm.4 @@ -509,6 +509,82 @@ See for a complete list of the supported .Fn ioctl functions. +.Ss kqueue Support +The +.Va kevent +structure's fields are defined as follows: +.Bl -tag -width "Fa filter" +.It Fa ident +The file descriptor for the device. +.It Fa filter +The kernel filter used to process the event. +This is either +.Dv EVFILT_READ +for recording or +.Dv EVFILT_WRITE +for playback. +.It Fa data +The number of bytes available to be read or written. +.It Fa ext +.Bl -bullet -compact +.It +.Va ext[0] +For devices that use +.Xr mmap 2 , +it contains the +.Va count_info.ptr +field reported by +.Va SNDCTL_DSP_GETIPTR +for recording or +.Va SNDCTL_DSP_GETOPTR +for playback, whereas for devices that do not use +.Xr mmap 2 , +it contains the +.Va oss_count_t.fifo_samples +field reported by +.Va SNDCTL_DSP_CURRENT_IPTR +for recording or +.Va SNDCTL_DSP_CURRENT_OPTR +for playback. +.It +.Va ext[1] +contains the +.Va audio_errinfo.rec_overruns +field for recording events, or the +.Va audio_errinfo.play_underruns +field for playback events, as reported by +.Va SNDCTL_DSP_GETERROR . +.Pp +This allows a single +.Va kevent +to report that data is ready, how many bytes can be read or written, the +current buffer position, and the current error count. +This is especially useful for scenarios that use +.Xr mmap 2 , +because without +.Xr kqueue 2 +the typical processing loop consists of: +.Bl -bullet -compact +.It +Calculating the wait time and calling +.Xr clock_nanosleep 2 . +.It +Calling +.Xr ioctl 2 +for +.Va SNDCTL_DSP_GETIPTR +or +.Va SNDCTL_DSP_GETOPTR +to get the pointer into the memory-mapped buffer where new data starts. +.It +Calling +.Xr ioctl 2 +for +.Va SNDCTL_DSP_GETERROR +to get over/underruns and handle them. +.El +.El +.El .Sh FILES The .Nm diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index f32446570374..fbe9f8a04325 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -3011,10 +3011,20 @@ dsp_kqevent(struct knote *kn, long hint) } kn->kn_data = 0; if (chn_polltrigger(ch)) { - if (kn->kn_filter == EVFILT_READ) + if (kn->kn_filter == EVFILT_READ) { kn->kn_data = sndbuf_getready(ch->bufsoft); - else + if (ch->flags & CHN_F_MMAP) + kn->kn_kevent.ext[0] = sndbuf_getfreeptr(ch->bufsoft); + else + kn->kn_kevent.ext[0] = sndbuf_getready(ch->bufsoft) / ch->bufsoft->align; + } else { kn->kn_data = sndbuf_getfree(ch->bufsoft); + if (ch->flags & CHN_F_MMAP) + kn->kn_kevent.ext[0] = sndbuf_getreadyptr(ch->bufsoft); + else + kn->kn_kevent.ext[0] = sndbuf_getready(ch->bufsoft) / ch->bufsoft->align; + } + kn->kn_kevent.ext[1] = ch->xruns; } return (kn->kn_data > 0);