shithub: riscv

Download patch

ref: dc593372bfc4224c6cf91d2031d0ad0aeadaddfe
parent: 5e370061e07ff96868ead6138fa552f6c3a5c4bd
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jan 6 14:55:38 EST 2024

nusb/audio: name audio device as audioUxxxx/volumeUxxxx (thanks arne)

This allows having multiple audio devices.

--- a/sys/man/4/nusb
+++ b/sys/man/4/nusb
@@ -272,8 +272,12 @@
 configures and manages a USB audio device.
 It implements a file system (normally seen under
 .BR /dev ),
-compatible with
-.IR audio (3).
+exporting
+.BN audioU N
+and
+.BI volumeU N
+files that have the same semantics as
+.IR audio (1)).
 .SS Camera devices
 .I Cam
 configures and exposes a USB camera device's capabilities,
--- a/sys/src/cmd/nusb/audio/audio.c
+++ b/sys/src/cmd/nusb/audio/audio.c
@@ -395,9 +395,9 @@
 	devctl(d, "sampledelay %d", audiodelay);
 	devctl(d, "hz %d", speed);
 	if(e->dir==Ein)
-		devctl(d, "name audioin");
+		devctl(d, "name audioinU%s", audiodev->hname);
 	else
-		devctl(d, "name audio");
+		devctl(d, "name audioU%s", audiodev->hname);	
 	return d;
 }
 
@@ -549,7 +549,8 @@
 		sysfatal("no output stream found");
 
 	fs.tree = alloctree(user, "usb", DMDIR|0555, nil);
-	createfile(fs.tree->root, "volume", user, 0666, nil);
+	snprint(buf, sizeof buf, "volumeU%s", audiodev->hname);
+	createfile(fs.tree->root, buf, user, 0666, nil);
 
 	snprint(buf, sizeof buf, "%d.audio", audiodev->id);
 	postsharesrv(&fs, nil, "usb", buf);