On Tue, Nov 17, 2020 at 05:09:28PM +0000, Stuart Henderson wrote:
> On 2020/11/17 17:13, Peter J. Philipp wrote:
> > Hi,
> >
> > I have a mic on snd/1 and speakers on snd/0. I had tried a lot of different
> > settings with audacity port but couldn't get this to work, so I chose the
> > method of last resort. Below is a patch to allow an AUDIORECDEVICE
> > environment
> > variable specifying the wanted microphone.
>
> This seems a worthwhile addition.
>
> > Index: sio.c
> > ===================================================================
> > RCS file: /cvs/src/lib/libsndio/sio.c,v
> > retrieving revision 1.24
> > diff -u -p -u -r1.24 sio.c
> > --- sio.c 29 Jun 2019 06:05:26 -0000 1.24
> > +++ sio.c 17 Nov 2020 16:13:04 -0000
> > @@ -43,6 +43,7 @@ sio_open(const char *str, unsigned int m
> > {
> > static char devany[] = SIO_DEVANY;
> > struct sio_hdl *hdl;
> > + char *rec = NULL;
> >
> > #ifdef DEBUG
> > _sndio_debug_init();
> > @@ -55,6 +56,12 @@ sio_open(const char *str, unsigned int m
> > str = getenv("AUDIODEVICE");
> > if (str == NULL)
> > str = devany;
> > + rec = getenv("AUDIORECDEVICE");
> > + if (rec == NULL)
> > + rec = devany;
> > +
> > + if (rec && mode == SIO_REC)
> > + str = rec;
>
> If AUDIORECDEVICE is unset, it would be better to fallback to
> AUDIODEVICE rather than directly to devany.
>
Thanks; semarie suggested a similar diff, so below is an attempt to
take into account all the suggestions:
- add AUDIOPLAYDEVICE, to handle play-only devices as well. We've the
very same problem for them.
- use AUDIODEVICE if play-only (rec-only) mode is used but the
corresponding AUDIOPLAYDEVICE (AUDIORECDEVICE) var is not defined
- minimal update for AUDIO{PLAY,REC}DEVICE in the man page
OK?
Index: sio.c
===================================================================
RCS file: /cvs/src/lib/libsndio/sio.c,v
retrieving revision 1.24
diff -u -p -r1.24 sio.c
--- sio.c 29 Jun 2019 06:05:26 -0000 1.24
+++ sio.c 18 Nov 2020 09:49:24 -0000
@@ -52,7 +52,12 @@ sio_open(const char *str, unsigned int m
if (str == NULL) /* backward compat */
str = devany;
if (strcmp(str, devany) == 0 && !issetugid()) {
- str = getenv("AUDIODEVICE");
+ if ((mode & SIO_PLAY) == 0)
+ str = getenv("AUDIORECDEVICE");
+ if ((mode & SIO_REC) == 0)
+ str = getenv("AUDIOPLAYDEVICE");
+ if (mode == (SIO_PLAY | SIO_REC) || str == NULL)
+ str = getenv("AUDIODEVICE");
if (str == NULL)
str = devany;
}
Index: sndio.7
===================================================================
RCS file: /cvs/src/lib/libsndio/sndio.7,v
retrieving revision 1.24
diff -u -p -r1.24 sndio.7
--- sndio.7 18 Jul 2020 05:01:14 -0000 1.24
+++ sndio.7 18 Nov 2020 09:49:24 -0000
@@ -151,9 +151,11 @@ If
.Cm default
is used as the audio device, the program will use the
one specified in the
-.Ev AUDIODEVICE
-environment variable.
-If it is not set, the program first tries to connect to
+.Ev AUDIODEVICE , AUDIOPLAYDEVICE
+and/or
+.Ev AUDIORECDEVICE
+environment variables.
+If they are not set, the program first tries to connect to
.Li snd/0 .
If that fails, it then tries to use
.Li rsnd/0 .
@@ -190,10 +192,20 @@ and contains 128 bits of raw random data
If a session needs to be shared between multiple users, they
can connect to the server using the same cookie.
.Sh ENVIRONMENT
-.Bl -tag -width "AUDIODEVICEXXX" -compact
+.Bl -tag -width "AUDIOPLAYDEVICE" -compact
.It Ev AUDIODEVICE
Audio device descriptor to use
when no descriptor is explicitly specified to a program.
+.It Ev AUDIOPLAYDEVICE
+Audio device descriptor to use for play-only mode
+when no descriptor is explicitly specified to a program.
+Overrides
+.Ev AUDIODEVICE .
+.It Ev AUDIORECDEVICE
+Audio device descriptor to use for record-only mode
+when no descriptor is explicitly specified to a program.
+Overrides
+.Ev AUDIODEVICE .
.It Ev MIDIDEVICE
MIDI port descriptor to use
when no descriptor is explicitly specified to a program.