sndctl(8): Modify vchans only on supported directions

Currently mod_play_vchans() and mod_rec_vchans() run unconditionally,
even if the direction (playback, recording) is not supported by the
device. This results in the "autoconv" (see mod_autoconv()) control
failing when run on simplex devices, because we'll be trying to modify
vchans on an unsupported direction.

Test whether the direction is supported and silently move on if it
isn't.

Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
Differential Revision:	https://reviews.freebsd.org/D53233
This commit is contained in:
Christos Margiolis
2025-10-22 13:50:55 +02:00
parent daac364e61
commit 70b34fbdbe
+4
View File
@@ -830,6 +830,8 @@ mod_play_vchans(struct snd_dev *dp, void *arg)
if (dp->from_user)
return (-1);
if (!dp->play.pchans)
return (0);
snprintf(buf, sizeof(buf), "dev.pcm.%d.play.vchans", dp->unit);
@@ -873,6 +875,8 @@ mod_rec_vchans(struct snd_dev *dp, void *arg)
if (dp->from_user)
return (-1);
if (!dp->rec.pchans)
return (0);
snprintf(buf, sizeof(buf), "dev.pcm.%d.rec.vchans", dp->unit);