9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Arne Meyer <meyer.arne83@netcologne.de>
To: 9front@9front.org
Subject: Re: [9front] [PATCH] Fix nusb/audio /dev entries
Date: Thu, 21 Dec 2023 21:12:37 +0100 (CET)	[thread overview]
Message-ID: <193272321.3542789.1703189557177@comcenter.netcologne.de> (raw)
In-Reply-To: <CAFSF3XNN4r-Hpza-ipyr9zfCVkuNF6kJ9QfHLcKXzo-br__yXA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 274 bytes --]

Ok,

how about this? Bring audio more in line with the rest of nusb. Postfix all
the device nodes with U<hname> so we can have as much usb audio devices as we like
and are not dependent on bind order. 
The nusbaudio script can be put in termrc to provide the "old" behavior.

[-- Attachment #2: nusbaudio.patch --]
[-- Type: application/octet-stream, Size: 1430 bytes --]

diff 34e7b54c139826b55713702910a1280e6651df60 uncommitted
--- /dev/null
+++ b/rc/bin/nusbaudio
@@ -1,0 +1,28 @@
+#!/bin/rc
+
+if(! test -e /dev/audio)
+	aux/stub /dev/audio
+if(! test -e /dev/volume)
+	aux/stub /dev/volume
+
+@{
+	rfork e
+	fn attach {
+		switch($4){
+		case *01
+			sleep 2
+			bind /dev/audioU$5 /dev/audio
+			bind /dev/volumeU$5 /dev/volume
+		}
+	}
+
+	fn detach {
+		switch($4){
+		case *01
+			unmount /dev/audio
+			unmount /dev/volume
+		}
+	}
+
+	rc < '#σ/usb/usbevent' &
+}
--- a/sys/src/cmd/nusb/audio/audio.c
+++ b/sys/src/cmd/nusb/audio/audio.c
@@ -365,6 +365,7 @@
 	int dir = e->dir;
 	Aconf *c;
 	Range *f;
+	char buf[32];
 
 	for(;e != nil; e = e->next){
 		c = e->iface->aux;
@@ -395,9 +396,12 @@
 	devctl(d, "sampledelay %d", audiodelay);
 	devctl(d, "hz %d", speed);
 	if(e->dir==Ein)
-		devctl(d, "name audioin");
+		snprint(buf, sizeof buf, "name audioinU%s", audiodev->hname); 
 	else
-		devctl(d, "name audio");
+		snprint(buf, sizeof buf, "name audioU%s", audiodev->hname);
+	
+	devctl(d, buf);
+
 	return d;
 }
 
@@ -549,7 +553,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);

  reply	other threads:[~2023-12-21 20:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-20 11:23 Arne Meyer
2023-12-20 16:44 ` qwx
2023-12-20 17:19   ` Kurt H Maier
2023-12-20 17:47     ` qwx
2023-12-20 17:51       ` Kurt H Maier
2023-12-20 18:11         ` qwx
2023-12-20 18:53   ` Arne Meyer
2023-12-20 23:10     ` qwx
2023-12-21  2:47     ` Sigrid Solveig Haflínudóttir
2023-12-21  7:53       ` hiro
2023-12-21 20:12         ` Arne Meyer [this message]
2023-12-21 20:48           ` hiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=193272321.3542789.1703189557177@comcenter.netcologne.de \
    --to=meyer.arne83@netcologne.de \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).