From nobody Sun Oct 20 11:21:35 2024 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 4XWbcH5j5wz5YvYV; Sun, 20 Oct 2024 11:21:35 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XWbcH2FVNz4WZ6; Sun, 20 Oct 2024 11:21:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729423295; 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=qgCFa9J9ejPZnjZbWbk/0AkARVvmusytk2eX5JKc18I=; b=n7uP1OlPFnvE5Tm0igMweZHbQARypazuWESBkwIZruh1Us+szFV1cT9fPILGc5zBZcHgoy UTxwF5xEvU7Ncgd19aj+LtOeoSvQAUjHlu4repLWOb8DXmP883nUgeuuzNJp1+nNGxHS7t ciFYFdPrvE9+xZyJHKtSBBZgLnhzsKEO+HB5xxniz3X+VzmtR20l2V2aSHixo2Ca/VVnR9 Qh9gn+u/IXG49P3YcRl23CjdFHDb0YrJ7IvvNtbIw6tC3XTq1OSrzjQ2+0WOKjErzp5fv9 iFvx455MBuQ2j6JfpI/eho8bhgvG152cowmoJnSmjpK+TJoxFHRXW1Sz2wMPlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729423295; 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=qgCFa9J9ejPZnjZbWbk/0AkARVvmusytk2eX5JKc18I=; b=xiEM4/nkpPXC/GBYj8/6Y+pOM/2wiW9yGc97IjZIlm+FgaGQA/7pEwCqdl68myjJQ4+Ph4 zZ5ViHmlKas/l8IH/lZUFCy7cbAav+LB8MobZSimNCKoJ3cKtDTxCxLc0m6ujrnfyM8v9t cLyZEX0+3pCU2eyBO/0m+9yWVgp0/N1M5eFaZ8fMagE8BOuUlA6RmaQ6bFVhubMuVWS0Zj KA3MseVsGF4s4BCh155xq2pgsvlLO1esnTN0MMzhv0vyXJgtK/hqoCHPDLmFJx6wJ2ACPp lRqmUpgVJF1l9PjLkc8bSDWLgd7oS1o9rJzMAeBCxF7s9xptIUrqjPuXCh8rGQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729423295; a=rsa-sha256; cv=none; b=agHnPlfVFzqR2/he04OC25epFm+yMZEW6bhSZYrQNuOg7uNcM99BkLqz9sVSVgPMpf23gw MoCJVk+3OyYPpxA2gZ7DGp+ElFlaFTmq+Ev29E0XfPVuA1C4zJdQa4PivQnRyHuux9NwMv EMjM5RykimeCxgw+8HNCSHDnvKOVITzU1Y1JkrnmUZ66/CkhKMsWTJvjpZVSCGGX2WwA/K KJnTGzNjEfA0XFPTULY9otrq38iq5gZFQoZuEE0xQR0e6meKxIXnMuFBEbRMV85xi4RRIp c9TwBEk5xqCT+HUnFSnPsIivIJ5X/Nr6Hob/AQAOEpg20/yqYXOBOMkZuXOViA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XWbcH1rVLz108M; Sun, 20 Oct 2024 11:21:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49KBLZvs062724; Sun, 20 Oct 2024 11:21:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49KBLZc1062718; Sun, 20 Oct 2024 11:21:35 GMT (envelope-from git) Date: Sun, 20 Oct 2024 11:21:35 GMT Message-Id: <202410201121.49KBLZc1062718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 6cf4db422c21 - stable/14 - sound: Move global variable initialization to sound_modevent() 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 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/14 X-Git-Reftype: branch X-Git-Commit: 6cf4db422c21ab4a0c39ed3f7c5f5d864c8ea2a2 Auto-Submitted: auto-generated The branch stable/14 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=6cf4db422c21ab4a0c39ed3f7c5f5d864c8ea2a2 commit 6cf4db422c21ab4a0c39ed3f7c5f5d864c8ea2a2 Author: Christos Margiolis AuthorDate: 2024-10-18 08:39:46 +0000 Commit: Christos Margiolis CommitDate: 2024-10-20 11:21:04 +0000 sound: Move global variable initialization to sound_modevent() There is no reason to initialize global variables in feeder_register(), as these variables are unrelated to what the function does. Instead, initialize them during sound(4) load. Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: zlei Differential Revision: https://reviews.freebsd.org/D46749 (cherry picked from commit 0a0301deb5b6a9c66829dd20cff9d40c5ba9ad92) --- sys/dev/sound/pcm/feeder.c | 43 ------------------------------------------- sys/dev/sound/pcm/sound.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 43 deletions(-) diff --git a/sys/dev/sound/pcm/feeder.c b/sys/dev/sound/pcm/feeder.c index 716eb07feaae..87437c6d00b5 100644 --- a/sys/dev/sound/pcm/feeder.c +++ b/sys/dev/sound/pcm/feeder.c @@ -77,49 +77,6 @@ feeder_register(void *p) SLIST_INSERT_HEAD(&feedertab, fte, link); feedercnt++; - /* initialize global variables */ - - if (snd_verbose < 0 || snd_verbose > 4) - snd_verbose = 1; - - if (snd_unit < 0) - snd_unit = -1; - - if (snd_maxautovchans < 0 || - snd_maxautovchans > SND_MAXVCHANS) - snd_maxautovchans = 0; - - if (chn_latency < CHN_LATENCY_MIN || - chn_latency > CHN_LATENCY_MAX) - chn_latency = CHN_LATENCY_DEFAULT; - - if (chn_latency_profile < CHN_LATENCY_PROFILE_MIN || - chn_latency_profile > CHN_LATENCY_PROFILE_MAX) - chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT; - - if (feeder_rate_min < FEEDRATE_MIN || - feeder_rate_max < FEEDRATE_MIN || - feeder_rate_min > FEEDRATE_MAX || - feeder_rate_max > FEEDRATE_MAX || - !(feeder_rate_min < feeder_rate_max)) { - feeder_rate_min = FEEDRATE_RATEMIN; - feeder_rate_max = FEEDRATE_RATEMAX; - } - - if (feeder_rate_round < FEEDRATE_ROUNDHZ_MIN || - feeder_rate_round > FEEDRATE_ROUNDHZ_MAX) - feeder_rate_round = FEEDRATE_ROUNDHZ; - - if (bootverbose) - printf("%s: snd_unit=%d snd_maxautovchans=%d " - "latency=%d " - "feeder_rate_min=%d feeder_rate_max=%d " - "feeder_rate_round=%d\n", - __func__, snd_unit, snd_maxautovchans, - chn_latency, - feeder_rate_min, feeder_rate_max, - feeder_rate_round); - /* we've got our root feeder so don't veto pcm loading anymore */ pcm_veto_load = 0; diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 330c99de14d1..da28a267c81a 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -829,6 +829,51 @@ sound_oss_card_info(oss_card_info *si) /************************************************************************/ +static void +sound_global_init(void) +{ + if (snd_verbose < 0 || snd_verbose > 4) + snd_verbose = 1; + + if (snd_unit < 0) + snd_unit = -1; + + if (snd_maxautovchans < 0 || + snd_maxautovchans > SND_MAXVCHANS) + snd_maxautovchans = 0; + + if (chn_latency < CHN_LATENCY_MIN || + chn_latency > CHN_LATENCY_MAX) + chn_latency = CHN_LATENCY_DEFAULT; + + if (chn_latency_profile < CHN_LATENCY_PROFILE_MIN || + chn_latency_profile > CHN_LATENCY_PROFILE_MAX) + chn_latency_profile = CHN_LATENCY_PROFILE_DEFAULT; + + if (feeder_rate_min < FEEDRATE_MIN || + feeder_rate_max < FEEDRATE_MIN || + feeder_rate_min > FEEDRATE_MAX || + feeder_rate_max > FEEDRATE_MAX || + !(feeder_rate_min < feeder_rate_max)) { + feeder_rate_min = FEEDRATE_RATEMIN; + feeder_rate_max = FEEDRATE_RATEMAX; + } + + if (feeder_rate_round < FEEDRATE_ROUNDHZ_MIN || + feeder_rate_round > FEEDRATE_ROUNDHZ_MAX) + feeder_rate_round = FEEDRATE_ROUNDHZ; + + if (bootverbose) + printf("%s: snd_unit=%d snd_maxautovchans=%d " + "latency=%d " + "feeder_rate_min=%d feeder_rate_max=%d " + "feeder_rate_round=%d\n", + __func__, snd_unit, snd_maxautovchans, + chn_latency, + feeder_rate_min, feeder_rate_max, + feeder_rate_round); +} + static int sound_modevent(module_t mod, int type, void *data) { @@ -839,6 +884,7 @@ sound_modevent(module_t mod, int type, void *data) case MOD_LOAD: pcm_devclass = devclass_create("pcm"); pcmsg_unrhdr = new_unrhdr(1, INT_MAX, NULL); + sound_global_init(); break; case MOD_UNLOAD: if (pcmsg_unrhdr != NULL) {