[rescue] my NPR interview is up!

Greg rescue at sunhelp.org
Tue Jul 31 02:26:39 CDT 2001


> An "audio capture"
> library (which I guess fake liboss is) is only half the solution.  You
> have to actually make it work in your system.

the following code works fine to capture Bill's interview from RealPlayer,
and, when converted to the 64kbps mono MP3 format, the resulting file is
about 1.7MB.

it's slightly modified from an old posting to comp.unix.solaris. I no longer
have the article so I cannot give credit where credit is due.  but this is
extremely simple and, aside from the bogus formatting resulting from
cut'n'paste, could be cleaned up quite a bit before being used as an example
of how to use LD_PRELOAD to intercept library calls.  It could use
dlsym(RTLD_NEXT) to "nest" instead of using the underscored libc entry
points, for example.

#include <string.h>
#include <signal.h>
static int audiofd = -1;
static int docap = 0;
static void startcap()
{
docap = (!docap);
}
int open(char *fname, int oflag, int mode) {
int fd;
fd =  _open(fname, oflag, mode);
if(!strcmp(fname, "/dev/audio") ){
audiofd = fd;
signal(SIGUSR2, startcap);
}
return fd;
}
int close(int fd){

if( (audiofd != -1) && (fd == audiofd)){
audiofd = -1;
docap = 1;
signal(SIGUSR2, SIG_DFL);
}
return _close(fd);
}
int write(int fd, const void *buf, int size){
if( (audiofd != -1) && (fd == audiofd) && docap)
_write(2, buf, size);
return _write(fd, buf, size);
}

Just compile it to a shared object, run rvplayer with LD_PRELOAD pointing to
the shared object, and the (very) raw audio data will be written to stderr.
I then use sox to convert to the raw data to a well-defined audio file
format (RIFF, Sun/NeXT, etc.) and then convert to MP3.

-greg




More information about the rescue mailing list