Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 May 2024 19:31:40 GMT
From:      Christos Margiolis <christos@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0aa767021c19 - stable/14 - sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
Message-ID:  <202405251931.44PJVe4a043635@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by christos:

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

commit 0aa767021c19ece8ab5ba99eb65d045700b09869
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-05-23 00:57:55 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-05-25 19:31:26 +0000

    sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
    
    The current implementation (incorrectly) passes the channel encoding
    value to AFMT_CHANNEL(), which will always return 0, since the channel
    number bits are masked out by AFMT_ENCODING().
    
    Also add missing fmts initialization and aggregate encoding formats into
    it directly.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 day
    Reviewed by:    dev_submerge.ch
    Differential Revision:  https://reviews.freebsd.org/D45312
    
    (cherry picked from commit 425a7bc465d4a6393c88c2e79c5ad77befda2a97)
---
 sys/dev/sound/pcm/sndstat.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index bbcb2fda7c29..6880ce383ba4 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -330,7 +330,6 @@ sndstat_get_caps(struct snddev_info *d, bool play, uint32_t *min_rate,
     uint32_t *max_rate, uint32_t *fmts, uint32_t *minchn, uint32_t *maxchn)
 {
 	struct pcm_channel *c;
-	unsigned int encoding;
 	int dir;
 
 	dir = play ? PCMDIR_PLAY : PCMDIR_REC;
@@ -347,11 +346,11 @@ sndstat_get_caps(struct snddev_info *d, bool play, uint32_t *min_rate,
 		return;
 	}
 
+	*fmts = 0;
 	*min_rate = UINT32_MAX;
 	*max_rate = 0;
 	*minchn = UINT32_MAX;
 	*maxchn = 0;
-	encoding = 0;
 	CHN_FOREACH(c, d, channels.pcm) {
 		struct pcmchan_caps *caps;
 		int i;
@@ -364,9 +363,9 @@ sndstat_get_caps(struct snddev_info *d, bool play, uint32_t *min_rate,
 		*min_rate = min(caps->minspeed, *min_rate);
 		*max_rate = max(caps->maxspeed, *max_rate);
 		for (i = 0; caps->fmtlist[i]; i++) {
-			encoding |= AFMT_ENCODING(caps->fmtlist[i]);
-			*minchn = min(AFMT_CHANNEL(encoding), *minchn);
-			*maxchn = max(AFMT_CHANNEL(encoding), *maxchn);
+			*fmts |= AFMT_ENCODING(caps->fmtlist[i]);
+			*minchn = min(AFMT_CHANNEL(caps->fmtlist[i]), *minchn);
+			*maxchn = max(AFMT_CHANNEL(caps->fmtlist[i]), *maxchn);
 		}
 		CHN_UNLOCK(c);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405251931.44PJVe4a043635>