git: c58e41d899a7 - stable/15 - sound: Clarify userland/vchan relationship in sndstat feeder chain

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Tue, 18 Nov 2025 00:51:47 UTC
The branch stable/15 has been updated by christos:

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

commit c58e41d899a785abf1f075dfef3ed9c045d5ca23
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-11-10 16:15:36 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-11-18 00:51:21 +0000

    sound: Clarify userland/vchan relationship in sndstat feeder chain
    
    When vchans are enabled, the primary channels do not interact with
    userland, but with the vchans.
    
    With vchans enabled:
    
    $ sndctl feederchain
    dsp0.play.0.feederchain=[vchans -> [...] -> hardware]
    dsp0.record.0.feederchain=[hardware -> [...] -> vchans]
    
    With vchans disabled:
    
    $ sndctl feederchain
    dsp0.play.0.feederchain=[userland ->  [...] -> hardware]
    dsp0.record.0.feederchain=[hardware -> [...] -> userland]
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D53504
    
    (cherry picked from commit 59d7865d3c20e86b3c42096f4a8c06a5e2eebd29)
---
 sys/dev/sound/pcm/sndstat.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index 51d0fb3bb686..1a5bccd718b5 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -524,7 +524,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 			    c->parentchannel->name : "userland");
 		} else {
 			sbuf_printf(&sb, "[%s", (c->direction == PCMDIR_REC) ?
-			    "hardware" : "userland");
+			    "hardware" :
+			    ((d->flags & SD_F_PVCHANS) ? "vchans" : "userland"));
 		}
 		sbuf_printf(&sb, " -> ");
 		f = c->feeder;
@@ -561,7 +562,8 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 			    "userland" : c->parentchannel->name);
 		} else {
 			sbuf_printf(&sb, "%s]", (c->direction == PCMDIR_REC) ?
-			    "userland" : "hardware");
+			    ((d->flags & SD_F_RVCHANS) ? "vchans" : "userland") :
+			    "hardware");
 		}
 
 		CHN_UNLOCK(c);
@@ -1320,7 +1322,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 			    c->parentchannel->name : "userland");
 		} else {
 			sbuf_printf(s, "\t{%s}", (c->direction == PCMDIR_REC) ?
-			    "hardware" : "userland");
+			    "hardware" :
+			    ((d->flags & SD_F_PVCHANS) ? "vchans" : "userland"));
 		}
 		sbuf_printf(s, " -> ");
 		f = c->feeder;
@@ -1358,7 +1361,8 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 			    "userland" : c->parentchannel->name);
 		} else {
 			sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC) ?
-			    "userland" : "hardware");
+			    ((d->flags & SD_F_RVCHANS) ? "vchans" : "userland") :
+			    "hardware");
 		}
 
 		CHN_UNLOCK(c);