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.
This is a good suggestion! Thanks! I have updated the patch. I also
appreciate Solene's offer for manpage addition, thanks!
New diff follows... let me know if it can be done better, I won't be able
to update it until tomorrow.
-peter
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 17:18:57 -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 = str;
+
+ if (rec && mode == SIO_REC)
+ str = rec;
}
if (strcmp(str, devany) == 0) {
hdl = _sio_aucat_open("snd/0", mode, nbio);
Index: sioctl.c
===================================================================
RCS file: /cvs/src/lib/libsndio/sioctl.c,v
retrieving revision 1.1
diff -u -p -u -r1.1 sioctl.c
--- sioctl.c 26 Feb 2020 13:53:58 -0000 1.1
+++ sioctl.c 17 Nov 2020 17:18:57 -0000
@@ -28,6 +28,7 @@ sioctl_open(const char *str, unsigned in
{
static char devany[] = SIO_DEVANY;
struct sioctl_hdl *hdl;
+ char *rec = NULL;
#ifdef DEBUG
_sndio_debug_init();
@@ -38,6 +39,14 @@ sioctl_open(const char *str, unsigned in
str = getenv("AUDIODEVICE");
if (str == NULL)
str = devany;
+
+ rec = getenv("AUDIORECDEVICE");
+ if (rec == NULL)
+ rec = str;
+
+ if (rec && mode == SIO_REC)
+ str = rec;
+
}
if (strcmp(str, devany) == 0) {
hdl = _sioctl_aucat_open("snd/0", mode, nbio);