|
Dear friends,
I am forwarding this mail to you all to ask for advice. Antoine Lefebvre
has done a nice job at separating input and output devices for double-
device linux setups in order to be able to use two cards on the same
machine (full-duplex, hence).
I'd like to include the patch at least in the unofficial distribution
(so jpff may have a chance to see if it works at all before including
it in the official one) but I'm undecided on how to handle it, because
all the solutions I can think of have drawbacks.
solution 1: insert names for I/O devices in the configure process,
all defaulting to the same device (when no two-cards
setups are present), as in:
--output-device=DEV (default: dsp)
--input-device=DEV (default: dsp)
so that whatever is set gets compiled in.
Drawbacks: compile-time option
Plusses: should remain command-line compatible, simple
and clean job
solution 2: allow run-time options to carry the name of the device
(without the '/dev' of course - or perhaps with that too?),
as in: csound -o dsp -i dsp1 etc.
(this could be done like this: when csound reads the -[io]
option, it checks whether the given name matches a possible
device: if it does, 'tis the device, otherwise it's a
file)
Drawbacks: pretty ugly if you ask me, and not command-
line compatible (if that has some meaning),
not so simple
Plusses: run-time option, quite convenient when you are
juggling around with cards...
Advice is more than welcome (it is needed!).
ciao ciao
Nicola
P.S. jpff, I don't get any mail from the csound list since Feb.17; are
we all *that* busy? (I certainly did not write...)
------------------------------------------------------------------------
Nicola Bernardini
E-mail: nicb@axnet.it
Re graphics: A picture is worth 10K words -- but only those to describe
the picture. Hardly any sets of 10K words can be adequately described
with pictures.
---------- Forwarded message ----------
Date: Wed, 3 Mar 1999 17:39:33 -0500
From: Antoine Lefebvre
To: Nicola Bernardini
Subject: rtaudio.c modif for linux
Hello,
it is the first time I use CVS, it is a very great tool! So have have what you said me. I include the diff file of my patch. I don't put any notice about my modification because I don't know how you made that habitually.
The modification is very little as you see. The disavantage is that you have to recompile to change de devices choice...I should be a great idea to add a command line option.
The file rtlinux.diff is include
Thanks
--
Antoine Lefebvre
antoinelefebvre@softhome.net
http://pages.infinit.net/linux/music/music.html
--- rtlinux.c.orig Wed Mar 3 17:33:37 1999
+++ rtlinux.c Wed Mar 3 17:34:10 1999
@@ -10,8 +10,10 @@
#include
#include
-#define DSP_NAME "/dev/dsp"
-static int dspfd;
+#define DSPIN_NAME "/dev/dsp1"
+#define DSPOUT_NAME "/dev/dsp"
+static int dspinfd;
+static int dspoutfd
void setsndparms(int, int, int, float, unsigned);
void setvolume(unsigned);
@@ -45,11 +47,11 @@
oMaxLag = IODACSAMPS; /* use the default value */
/* Jonathan Mohr 1995 Oct 17 */
/* open DSP device for reading */
- if ( (dspfd = open(DSP_NAME, O_RDONLY)) == -1 )
+ if ( (dspinfd = open(DSPIN_NAME, O_RDONLY)) == -1 )
die("unable to open soundcard for audio input");
/* initialize data format, channels, sample rate, and buffer size */
- setsndparms( dspfd, O.informat, nchnls, esr, oMaxLag * O.insampsiz );
+ setsndparms( dspinfd, O.informat, nchnls, esr, oMaxLag * O.insampsiz );
ishift = getshift(dsize);
}
@@ -67,11 +69,11 @@
channels, but allows the user to set the output volume. */
{
/* open DSP device for writing */
- if ( (dspfd = open(DSP_NAME, O_WRONLY)) == -1 )
+ if ( (dspoutfd = open(DSPOUT_NAME, O_WRONLY)) == -1 )
die("unable to open soundcard for audio output");
/* set sample size/format, rate, channels, and DMA buffer size */
- setsndparms( dspfd, O.outformat, nchnls, esr,
+ setsndparms( dspoutfd, O.outformat, nchnls, esr,
O.outbufsamps * O.outsampsiz);
/* check if volume was specified as command line parameter */
@@ -90,7 +92,7 @@
int rtrecord(char *inbuf, int nbytes) /* get samples from ADC */
{
/* J. Mohr 1995 Oct 17 */
- if ( (nbytes = read(dspfd, inbuf, nbytes)) == -1 )
+ if ( (nbytes = read(dspinfd, inbuf, nbytes)) == -1 )
die("error while reading DSP device for audio input");
return(nbytes);
}
@@ -110,7 +112,7 @@
{
long sampframes = nbytes >> oshift;
/* J. Mohr 1995 Oct 17 */
- if (write(dspfd, outbuf, nbytes) < nbytes)
+ if (write(dspoutfd, outbuf, nbytes) < nbytes)
printf("/dev/dsp: couldn't write all bytes requested\n");
nrecs++;
}
@@ -118,7 +120,9 @@
void rtclose(void) /* close the I/O device entirely */
{ /* called only when both complete */
/* J. Mohr 1995 Oct 17 */
- if (close(dspfd) == -1)
+ if (close(dspinfd) == -1)
+ die("unable to close DSP device");
+ if (close(dspoutfd) == -1)
die("unable to close DSP device");
if (O.Linein) {
#ifdef PIPES
|