A friend of mine gave me a C program that opens and plays .wav files. It follows:#include #include #include #include #include #define
int main(int argc,char *argv)
int devfd, sampfd;
unsigned char sampbuf[BUFSZ];
/* Open /dev/dsp/ */
if((devfd = open(dev,O_WRONLY)) < 0)
if(errno == EBUSY)
fprintf(stderr, "%s in use
fprintf(stderr, "%s: %s
if((sampfd=open(argv,O_RDONLY)) < 0)
/* Read a block, write a block */
while((len=read(sampfd,sampbuf,BUFSZ)) > 0)
/* Close the descriptors and get outta here */
First off, I'm using Mandrake.
If I use the command syntax cc play.c -o play I get an executable file that is able to 'play' standard .wav files, i.e. play mywave.wav.
If I use the command syntax cc play.c I get a.out of course, but when I try to execute it as a.out mywave.wav it plays this horrible screaching noise. The original executable file still works but I can't copy it to another filename w/o the same problem happening, i.e. cp play hold, etc. It also does weird stuff like if I move between default consoles and try to play the file by calling the previously executed command by using the 'up' arrow keys it tells me when I hit enter that the /dev/dsp device is busy. Someone told me that he thinks that it has to do w/the argv, argc variables and that the a.out file is attempting to play itself. Any suggestions. Thanks.