From nobody Mon Sep 07 14:48: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 4hdqh16Hs6z6rX6K for ; Mon, 07 Sep 2026 14:48: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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hdqh15lr8z44hg for ; Mon, 07 Sep 2026 14:48:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788792513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uRtQgwvNHm9doOks+BF4XMehQuXtonpgFiocgyyOn78=; b=Wrp43ZFDhor/L1RBbAFUhAiE2N0aiuNadq31i0BP6P3I+qMBvbV1gAK6PSs1omnY5FVR0r 0j4qY9ezIaJp8u6N/OtvGV6CMtTJL3SfexFo9+dnOmjwxXWfDhY1kHzMgfBwwgjvqkCaAZ SqK5RkTtixpVgbavJLBAgKLy19vc1+wYvtH6Yhz+k/8Q5oGTIFiaCUh97UU9UlT0bdvtWe RyeGtPx+E+Hh8fflB5PbZhp/w/y9YAXLQc4TAxy/gQTLH9acXYxU0ONASPi3gOxdNRknIq BDK8wkbpD6pWH+XrteDyBKyQW2YsSoNmIe63Nd1w0yTtSc2A3z1IYqRntbBVRg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788792513; a=rsa-sha256; cv=none; b=tTtxlIZYPN8RJjb044xUGwCFgI0VRZDvTSdQ9zuMkMv1pWEPYQAO92f1g7TVB77+2RHntI CXjrGV0kDRlEyOvPa3T6SCWv6hNWGQSmjhVKB4UGymwQEzNLXRAzTyjNCXD4lu6BkcKGiM 5Dl8V0oB427Xk3/bT7+GybQ0XEEwQGPWAGaRI6EC1Knb9kExNLAZO10ZTdBC0h9axNObb1 j1D/97dy8yb6sh1gnHgtcV2RY8PH4TPd6nBpQ6IOskoM7lhsPV7l6n48IDBarPe4fhCZIU 8Qo+FUvfRUY1HiWRpVdMdSSZR+4y9rC8aneiQ7q11ttcYytWcElUdNDJwKELOA== 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=1788792513; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uRtQgwvNHm9doOks+BF4XMehQuXtonpgFiocgyyOn78=; b=HmoB7BbODHswsew2Z5I+jI0vd6iylTgEK1P2V8GXMn4m22a0ZM2IZumgxlm/+FV+xvzH9W s/iyjwoCxmBfoJMOKo3loyVWD5KxpZgEPqhSYHvp4ZkgFTWNi/4QfCloeo34hD5MPfZFCk nmLWIF7emnK26d/cs/h+lsf8O+MZQeZALHP9OTmCuN3CI6wz8WBMmqft+PsHps7O6pNgkU VCYPZNxw8EkCUPf0B21aad5E1kxmtLyoDQJcLD62VUBDjY2ZoJQu6kEZYuoSHot92luiC1 ZJ7xE3ACeFrpeJIOw3Y/g3E2lcsHIwCYIMhQlDQO41qWkyL+iYlNTH23TIRaug== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hdqh13x53z6nJ for ; Mon, 07 Sep 2026 14:48:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d560 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 07 Sep 2026 14:48:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: a7258157e1a2 - main - snd_emu10kx: Make sure the block count and size cover the whole buffer 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/main X-Git-Reftype: branch X-Git-Commit: a7258157e1a20957af23332814197ea723f5778d Auto-Submitted: auto-generated Date: Mon, 07 Sep 2026 14:48:33 +0000 Message-Id: <6a9ecec1.3d560.31d0c477@gitrepo.freebsd.org> The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=a7258157e1a20957af23332814197ea723f5778d commit a7258157e1a20957af23332814197ea723f5778d Author: Christos Margiolis AuthorDate: 2026-09-07 14:48:21 +0000 Commit: Christos Margiolis CommitDate: 2026-09-07 14:48:21 +0000 snd_emu10kx: Make sure the block count and size cover the whole buffer The playback voices always loop over the whole EMU_PLAY_BUFSZ buffer, but emupchan_setblocksize() only recorded the new block size and left the block count as it was set up by emu_vinit(). The blocks then no longer covered the whole buffer, and the part they left out was played without ever being written to, which became audible as distortion once playback started going through a virtual channel. Resize the buffer, so that the block count and size always cover it. Fixes: 02d4eeabfd73 ("sound: Allocate vchans on-demand") PR: 287687 MFC after: 1 week Sponsored by: The FreeBSD Foundation Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D59444 --- sys/dev/sound/pci/emu10kx-pcm.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sys/dev/sound/pci/emu10kx-pcm.c b/sys/dev/sound/pci/emu10kx-pcm.c index 7cb371d82d39..0a15b8ba3448 100644 --- a/sys/dev/sound/pci/emu10kx-pcm.c +++ b/sys/dev/sound/pci/emu10kx-pcm.c @@ -768,13 +768,30 @@ emupchan_setblocksize(kobj_t obj __unused, void *c_devinfo, uint32_t blocksize) { struct emu_pcm_pchinfo *ch = c_devinfo; struct emu_pcm_info *sc = ch->pcm; + uint32_t blkcnt; + + /* + * The channel always plays the whole EMU_PLAY_BUFSZ buffer, so the + * blocks have to cover it exactly, or the part they do not cover is + * "played" without ever being written to. + * + * sndbuf_resize() needs at least two blocks, so a block can be at most + * half the buffer's size. The block count has to be a power of two as + * well, because only then does the division come out exact. + */ + if (blocksize == 0 || blocksize > EMU_PLAY_BUFSZ / 2) + blocksize = EMU_PLAY_BUFSZ / 2; + blkcnt = 1 << (fls(EMU_PLAY_BUFSZ / blocksize) - 1); + blocksize = EMU_PLAY_BUFSZ / blkcnt; + + if (sndbuf_resize(ch->buffer, blkcnt, blocksize) != 0) + return (ch->blksz); - if (blocksize > ch->pcm->bufsz) - blocksize = ch->pcm->bufsz; mtx_lock(&sc->lock); ch->blksz = blocksize; emu_timer_set(sc->card, ch->timer, ch->blksz / ch->buffer->align); mtx_unlock(&sc->lock); + return (ch->blksz); }