sound: Improve sndstat nvlist feederchain format

- Use snd_afmt2str() to display format conversions in feeder_format,
  instead of the plain hex value.
- Simplify feeder_rate contents.
- Print "ch" (e.g 2.1ch) after matrix values in feeder_matrix.
- Use snd_afmt2str() instead of a plain hex for the the rest of the
  feeder classes.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46309
This commit is contained in:
Christos Margiolis 2024-08-24 15:07:54 +03:00
parent 6747b1a821
commit 0864dfe629

View File

@ -388,6 +388,7 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
uint32_t maxrate, minrate, fmts, minchn, maxchn, caps; uint32_t maxrate, minrate, fmts, minchn, maxchn, caps;
nvlist_t *di = NULL, *sound4di = NULL, *diinfo = NULL, *cdi = NULL; nvlist_t *di = NULL, *sound4di = NULL, *diinfo = NULL, *cdi = NULL;
int err, nchan; int err, nchan;
char buf[AFMTSTR_LEN];
di = nvlist_create(0); di = nvlist_create(0);
if (di == NULL) { if (di == NULL) {
@ -531,10 +532,12 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
while (f != NULL) { while (f != NULL) {
sbuf_printf(&sb, "%s", f->class->name); sbuf_printf(&sb, "%s", f->class->name);
if (f->desc->type == FEEDER_FORMAT) { if (f->desc->type == FEEDER_FORMAT) {
sbuf_printf(&sb, "(0x%08x -> 0x%08x)", snd_afmt2str(f->desc->in, buf, sizeof(buf));
f->desc->in, f->desc->out); sbuf_printf(&sb, "(%s -> ", buf);
snd_afmt2str(f->desc->out, buf, sizeof(buf));
sbuf_printf(&sb, "%s)", buf);
} else if (f->desc->type == FEEDER_MATRIX) { } else if (f->desc->type == FEEDER_MATRIX) {
sbuf_printf(&sb, "(%d.%d -> %d.%d)", sbuf_printf(&sb, "(%d.%dch -> %d.%dch)",
AFMT_CHANNEL(f->desc->in) - AFMT_CHANNEL(f->desc->in) -
AFMT_EXTCHANNEL(f->desc->in), AFMT_EXTCHANNEL(f->desc->in),
AFMT_EXTCHANNEL(f->desc->in), AFMT_EXTCHANNEL(f->desc->in),
@ -542,15 +545,12 @@ sndstat_build_sound4_nvlist(struct snddev_info *d, nvlist_t **dip)
AFMT_EXTCHANNEL(f->desc->out), AFMT_EXTCHANNEL(f->desc->out),
AFMT_EXTCHANNEL(f->desc->out)); AFMT_EXTCHANNEL(f->desc->out));
} else if (f->desc->type == FEEDER_RATE) { } else if (f->desc->type == FEEDER_RATE) {
sbuf_printf(&sb, sbuf_printf(&sb, "(%d -> %d)",
"(0x%08x q:%d %d -> %d)",
f->desc->out,
FEEDER_GET(f, FEEDRATE_QUALITY),
FEEDER_GET(f, FEEDRATE_SRC), FEEDER_GET(f, FEEDRATE_SRC),
FEEDER_GET(f, FEEDRATE_DST)); FEEDER_GET(f, FEEDRATE_DST));
} else { } else {
sbuf_printf(&sb, "(0x%08x)", snd_afmt2str(f->desc->out, buf, sizeof(buf));
f->desc->out); sbuf_printf(&sb, "(%s)", buf);
} }
sbuf_printf(&sb, " -> "); sbuf_printf(&sb, " -> ");
f = f->parent; f = f->parent;