git: b58d9db4d77a - main - sound: Fix VCHANs' starting and ending points in feeder chain

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Fri, 02 Aug 2024 12:53:51 UTC
The branch main has been updated by christos:

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

commit b58d9db4d77a6f42ac7cf3cdb2af2443666033e2
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2024-08-02 12:53:16 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2024-08-02 12:53:16 +0000

    sound: Fix VCHANs' starting and ending points in feeder chain
    
    sndstat(4) falsely reports "hardware" as the starting point of
    recording, and ending point of playback VCHANs. Recording VCHANs get
    their input from the primary recording channel, and playback VCHANs send
    their input to the primary playback channel.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 days
    Reviewed by:    dev_submerge.ch, markj
    Differential Revision:  https://reviews.freebsd.org/D46177
---
 sys/dev/sound/pcm/sndstat.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c
index f09fa7139884..4fac6a97a3f0 100644
--- a/sys/dev/sound/pcm/sndstat.c
+++ b/sys/dev/sound/pcm/sndstat.c
@@ -517,8 +517,13 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 		nvlist_add_number(cdi, SNDST_DSPS_SOUND4_CHAN_SWBUF_READY,
 		    sndbuf_getready(c->bufsoft));
 
-		sbuf_printf(&sb, "[%s",
-		    (c->direction == PCMDIR_REC) ? "hardware" : "userland");
+		if (c->parentchannel != NULL) {
+			sbuf_printf(&sb, "[%s", (c->direction == PCMDIR_REC) ?
+			    c->parentchannel->name : "userland");
+		} else {
+			sbuf_printf(&sb, "[%s", (c->direction == PCMDIR_REC) ?
+			    "hardware" : "userland");
+		}
 		sbuf_printf(&sb, " -> ");
 		f = c->feeder;
 		while (f->source != NULL)
@@ -550,8 +555,13 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
 			sbuf_printf(&sb, " -> ");
 			f = f->parent;
 		}
-		sbuf_printf(&sb, "%s]",
-		    (c->direction == PCMDIR_REC) ? "userland" : "hardware");
+		if (c->parentchannel != NULL) {
+			sbuf_printf(&sb, "%s]", (c->direction == PCMDIR_REC) ?
+			    "userland" : c->parentchannel->name);
+		} else {
+			sbuf_printf(&sb, "%s]", (c->direction == PCMDIR_REC) ?
+			    "userland" : "hardware");
+		}
 
 		CHN_UNLOCK(c);
 
@@ -1306,8 +1316,13 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 		sbuf_printf(s, "channel flags=0x%b", c->flags, CHN_F_BITS);
 		sbuf_printf(s, "\n\t");
 
-		sbuf_printf(s, "{%s}",
-		    (c->direction == PCMDIR_REC) ? "hardware" : "userland");
+		if (c->parentchannel != NULL) {
+			sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC) ?
+			    c->parentchannel->name : "userland");
+		} else {
+			sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC) ?
+			    "hardware" : "userland");
+		}
 		sbuf_printf(s, " -> ");
 		f = c->feeder;
 		while (f->source != NULL)
@@ -1339,8 +1354,13 @@ sndstat_prepare_pcm(struct sbuf *s, device_t dev, int verbose)
 			sbuf_printf(s, " -> ");
 			f = f->parent;
 		}
-		sbuf_printf(s, "{%s}",
-		    (c->direction == PCMDIR_REC) ? "userland" : "hardware");
+		if (c->parentchannel != NULL) {
+			sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC) ?
+			    "userland" : c->parentchannel->name);
+		} else {
+			sbuf_printf(s, "{%s}", (c->direction == PCMDIR_REC) ?
+			    "userland" : "hardware");
+		}
 
 		CHN_UNLOCK(c);
 	}