[virtual_oss][PATCH] virtual_oss: Retire -T option

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Tue, 11 Mar 2025 21:33:57 UTC
Posting it here for review since more people will see it here than in
the GitHub page. Related discussion:
https://lists.freebsd.org/archives/freebsd-multimedia/2025-March/002887.html

What the argument -T expects, is always going to be /dev/sndstat, so the
option is quite redundant in the first place. There is also no good
reason not to want to register the device to /dev/sndstat.

Sponsored by:	The FreeBSD Foundation
---
 rc.d/virtual_oss.in |  2 --
 virtual_int.h       |  1 -
 virtual_main.c      | 24 +++++++-----------------
 virtual_oss.8       |  2 --
 4 files changed, 7 insertions(+), 22 deletions(-)

diff --git a/rc.d/virtual_oss.in b/rc.d/virtual_oss.in
index 534af79..090f47d 100644
--- a/rc.d/virtual_oss.in
+++ b/rc.d/virtual_oss.in
@@ -16,7 +16,6 @@
 #                               Default is "dsp"
 # virtual_oss_dsp (string):     Arguments passed to virtual_oss config named dsp
 #                               Default is
-#                                   -T /dev/sndstat # register vdsp in sndstat
 #                                   -C 2 -c 2 # use two channels
 #                                   -S # resample if needed
 #                                   -i 8 # real-time priority
@@ -39,7 +38,6 @@ status_cmd="${name}_status"
 
 # required_modules="cuse"
 virtual_oss_default_args="\
-  -T /dev/sndstat \
   -S \
   -i 8 \
   -C 2 -c 2 \
diff --git a/virtual_int.h b/virtual_int.h
index 5f10a8f..649e464 100644
--- a/virtual_int.h
+++ b/virtual_int.h
@@ -225,7 +225,6 @@ extern int voss_has_synchronization;
 extern char voss_dsp_rx_device[VMAX_STRING];
 extern char voss_dsp_tx_device[VMAX_STRING];
 extern char voss_ctl_device[VMAX_STRING];
-extern char voss_sta_device[VMAX_STRING];
 
 extern void atomic_lock(void);
 extern void atomic_unlock(void);
diff --git a/virtual_main.c b/virtual_main.c
index 96fada6..b2036fe 100644
--- a/virtual_main.c
+++ b/virtual_main.c
@@ -1639,7 +1639,6 @@ uint32_t voss_dsp_tx_refresh;
 char voss_dsp_rx_device[VMAX_STRING];
 char voss_dsp_tx_device[VMAX_STRING];
 char voss_ctl_device[VMAX_STRING];
-char voss_sta_device[VMAX_STRING];
 
 uint32_t voss_jitter_up;
 uint32_t voss_jitter_down;
@@ -1694,7 +1693,6 @@ usage(void)
 	    "\t" "-C 2 -c 2 -r 48000 -b 16 -s 100.0ms -f /dev/dsp3 \\\n"
 	    "\t" "-P /dev/dsp3 -R /dev/dsp1 \\\n"
 	    "\t" "-O /dev/dsp3 -R /dev/null \\\n"
-	    "\t" "-T /dev/sndstat \\\n"
 	    "\t" "-c 1 -m 0,0 [-w wav.0] -d dsp100.0 \\\n"
 	    "\t" "-c 1 -m 0,0 [-w wav.0] -d vdsp.0 \\\n"
 	    "\t" "-c 2 -m 0,0,1,1 [-w wav.1] -d vdsp.1 \\\n"
@@ -1908,14 +1906,12 @@ dup_profile(vprofile_t *pvp, int *pamp, int pol, int rx_mute,
 			return ("Could not create CUSE DSP device");
 		}
 
-		/* register sndstat, if any */
-		if (voss_sta_device[0] != 0) {
-			ptr->fd_sta = open(voss_sta_device, O_WRONLY);
-			if (ptr->fd_sta < 0) {
-				warn("Could not open '%s'", voss_sta_device);
-			} else {
-				init_sndstat(ptr);
-			}
+		/* register to sndstat */
+		ptr->fd_sta = open("/dev/sndstat", O_WRONLY);
+		if (ptr->fd_sta < 0) {
+			warn("Could not open /dev/sndstat");
+		} else {
+			init_sndstat(ptr);
 		}
 	}
 	/* create WAV device */
@@ -2017,7 +2013,7 @@ parse_options(int narg, char **pparg, int is_main)
 	float samples_ms;
 
 	if (is_main)
-		optstr = "N:J:k:H:o:F:G:w:e:p:a:C:c:r:b:f:g:x:i:m:M:d:l:L:s:t:h?O:P:Q:R:ST:BD:E:";
+		optstr = "N:J:k:H:o:F:G:w:e:p:a:C:c:r:b:f:g:x:i:m:M:d:l:L:s:t:h?O:P:Q:R:SBD:E:";
 	else
 		optstr = "F:G:w:e:p:a:c:b:f:m:M:d:l:L:s:O:P:R:E:";
 
@@ -2286,12 +2282,6 @@ parse_options(int narg, char **pparg, int is_main)
 			if (voss_dsp_samples >= (1U << 24))
 				return ("-s option requires a non-zero positive value");
 			break;
-		case 'T':
-			if (voss_sta_device[0])
-				return ("-T parameter may only be used once");
-
-			strncpy(voss_sta_device, optarg, sizeof(voss_sta_device));
-			break;
 		case 't':
 			if (voss_ctl_device[0])
 				return ("-t parameter may only be used once");
diff --git a/virtual_oss.8 b/virtual_oss.8
index e47d1c7..6aa9f12 100644
--- a/virtual_oss.8
+++ b/virtual_oss.8
@@ -155,8 +155,6 @@ Set recording DSP device only.
 Specifying /dev/null is magic and means no recording device.
 .It Fl f Ar devname
 Set both playback and recording DSP device
-.It Fl T Ar devname
-Install entry in /dev/sndstat.
 .It Fl w Ar name
 Create a WAV file format compatible companion device by given name.
 This option should be specified before the -d and -l options.
-- 
2.48.1