From nobody Mon Sep 14 10:45:08 2026 X-Original-To: dev-commits-src-branches@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 4hk1xx17pnz6sNRl for ; Mon, 14 Sep 2026 10:45:09 +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 4hk1xx0G4gz4pbB for ; Mon, 14 Sep 2026 10:45:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789382709; 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=xrEOFq96kZCEhRkYBZ5IoyE6oYFlHO+rMs+CyxF19HQ=; b=K/i1h8d9Ty4GyYDL3mO2Fg1+/n5Gibcnn+JjvWh6sX1rwhr6hXb/MhN2gVwbacMUjfW2X7 SkXF9miUcldPpLiRtab/JCibps2H4jP2q1QLeZZJTeta53GlU2OcQr85ynRvOwQTzGg5xz ZY/V6v9KNRAme0Q24Cwsxcw9vtjyVw9MzIRVkxj2RbX3nWVZ38Ee/uMILW2v5l4IWC5anT 82769ZVxcYWRrmQvQ148DwixoZKtNGKT00XOg4YIgYeDNqRgF/eQnnSurIllJdZ/KzYzbj vYJvzvSE84V0DYv75c9EgxFDVyZ66oO24YLsnC1fv7rIz0roM9Bn3EmEo5ff+Q== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1789382709; b=ZQaP3Xt6RzYlsI/+Ftg5DYnfFXLKQzaduLQNoQJf2neYUJd8jdj+YPRDFv3hyyeEyw3DvH QuRjh4lsg8r2kli6TGxL7PXDF5kzOymppcv0IIoC5A/oAL1nMfGoZouePYl076yBab70FZ R92GL2dIywQagARdiOqmeMasSfB3gIivaAZW6REWXVDCFZzNEbNpeYufoAEGybjFbngUcV 0FXVO76qTZT0RfwvCIvLd8V8cHvUftiPn15qVR3KxnPF4poveCHujbFjfPPpcf6dKPHvn6 dwSJnYQNStZHH7owj5uuvEAI6TK6nteR5R8mUzzIGslkQCUnCxSxdWxwYXWxtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1789382709; 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=xrEOFq96kZCEhRkYBZ5IoyE6oYFlHO+rMs+CyxF19HQ=; b=E2Q5mGUC0APPnavnbZycZFJTqDWuzFfCel/l0LHN4L/aPz+WRxoFnrvXQVh9QTYFUY9DJc rMt+X7LJmGqE56FDsWBYZOYnfr0ySNtPsWxxv3I9G5PrCIuN4DYY/tf4eb/EEohWiCYJ7H MZ4+u1XXVyaTCmkzo7H0/7OCQ1DGm7qwPO3pdp6gqf525zZMt4ePn4f6/ZwJ3FXJVwUg6z Pee5hCb9wNxCxOqm75szljzUgsaHwUErWY4KhJTWFqbtDERh8irkqRX+4AjsS0hBSTCwj8 youYjTF+s/WYiiTdN118v4gupFMzji+D/jNQSi56AuLIxQ/t1DHY+6RG7Pjt7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hk1xw68k3z1PNx for ; Mon, 14 Sep 2026 10:45:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 434e1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 14 Sep 2026 10:45:08 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: cbd730ebeb03 - stable/15 - snd_emu10kx: Make sure the block count and size cover the whole buffer List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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: cbd730ebeb03e26578bdef61669acca1cc7c65fa Auto-Submitted: auto-generated Date: Mon, 14 Sep 2026 10:45:08 +0000 Message-Id: <6aa7d034.434e1.450bf8ef@gitrepo.freebsd.org> The branch stable/15 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=cbd730ebeb03e26578bdef61669acca1cc7c65fa commit cbd730ebeb03e26578bdef61669acca1cc7c65fa Author: Christos Margiolis AuthorDate: 2026-09-07 14:48:21 +0000 Commit: Christos Margiolis CommitDate: 2026-09-14 10:44:57 +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 (cherry picked from commit a7258157e1a20957af23332814197ea723f5778d) --- 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); }