git: de8161712e23 - stable/14 - sound: Get rid of snd_sb16 workaround in vchan_create()

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Wed, 10 Jul 2024 16:48:59 UTC
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=de8161712e2349554529be24c9146a642e282953

commit de8161712e2349554529be24c9146a642e282953
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-07-06 18:22:16 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-07-10 16:48:12 +0000

    sound: Get rid of snd_sb16 workaround in vchan_create()
    
    The snd_sb16 driver was removed in 716924cb4832 ("Retire snd_sbc ISA
    sound card driver").
    
    While here, simplify sample rate assignment a bit.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch, markj, emaste
    Differential Revision:  https://reviews.freebsd.org/D45662
    
    (cherry picked from commit d6d4586b0b7e3b01812e6c26818af78bf9b680a3)
---
 sys/dev/sound/pcm/vchan.c | 28 +++++-----------------------
 1 file changed, 5 insertions(+), 23 deletions(-)

diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c
index 528c6fa62621..fa4fa2023b71 100644
--- a/sys/dev/sound/pcm/vchan.c
+++ b/sys/dev/sound/pcm/vchan.c
@@ -768,25 +768,10 @@ vchan_create(struct pcm_channel *parent)
 		    &vchanspd);
 		CHN_LOCK(parent);
 		if (r != 0) {
-			/*
-			 * No saved value, no hint, NOTHING.
-			 *
-			 * Workaround for sb16 running
-			 * poorly at 45k / 49k.
-			 */
-			switch (parent_caps->maxspeed) {
-			case 45000:
-			case 49000:
-				vchanspd = 44100;
-				break;
-			default:
-				vchanspd = VCHAN_DEFAULT_RATE;
-				if (vchanspd > parent_caps->maxspeed)
-					vchanspd = parent_caps->maxspeed;
-				break;
-			}
-			if (vchanspd < parent_caps->minspeed)
-				vchanspd = parent_caps->minspeed;
+			/* No saved value, no hint, NOTHING. */
+			vchanspd = VCHAN_DEFAULT_RATE;
+			RANGE(vchanspd, parent_caps->minspeed,
+			    parent_caps->maxspeed);
 		}
 		save = 1;
 	}
@@ -795,10 +780,7 @@ vchan_create(struct pcm_channel *parent)
 		/*
 		 * Limit the speed between feeder_rate_min <-> feeder_rate_max.
 		 */
-		if (vchanspd < feeder_rate_min)
-			vchanspd = feeder_rate_min;
-		if (vchanspd > feeder_rate_max)
-			vchanspd = feeder_rate_max;
+		RANGE(vchanspd, feeder_rate_min, feeder_rate_max);
 
 		if (feeder_rate_round) {
 			RANGE(vchanspd, parent_caps->minspeed,