Sound recording problems
Hi! I tried the linux-sound list without luck, so I try this list. I'm having recording troubles with my computer. I say my computer, because I've already tried 3 different sound cards, and 2 kernels, with strange results.
I'll focus on my actual configuration, so I can debug the problem. I have a SB16 Awe ISA, and I tried the OSS drivers with 2.6.0-test1. I have a VIAC686 motherboard, with a K7 650Mhz processor.
The sample program I attach, do record the sound. Please notice the commented snip that doesn't work, it is stopping a lot of programs from working.
Also, if I try doing a
cat /dev/dsp > bla.raw
the result file is full of 7F's (doesn't hear anything). This is just a sample of the problems I have with lots of other recording programs.
Can you help me debug this? What should I do? What information should I reunite?
Please reply to my own address, since I'm not subscribed to the list.
TIA!!
Signature · 1 line
Whip it, baby. Whip it right. Whip it, baby. Whip it all night!
// Stolen from nuvrec: http://mars.tuwien.ac.at/~roman/nuppelvideo/
#include <sys/soundcard.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <signal.h>
int ostr=0;
long audio_buffer_size=0;
static void sighandler(int i)
{
if (ostr) {
close(ostr); }
printf ("\n");
exit(0);
}
int main (int argc, char** argv) {
int afmt, afd, frag, channels, rate, blocksize, trigger, lastread;
char audiodevice[] = "/dev/dsp";
unsigned char* buffer;
ostr=open(argv[1],O_WRONLY|O_CREAT, 0644);
if (ostr==-1) return(-1);
if (-1 == (afd = open(audiodevice, O_RDONLY))) {
fprintf(stderr, "\n%s\n", "Cannot open DSP, exiting");
exit(1);
}
signal(SIGINT, sighandler); // install sighaendler
ioctl(afd, SNDCTL_DSP_RESET, 0);
frag=(8<<16)|(10);//8 buffers, 1024 bytes each
ioctl(afd, SNDCTL_DSP_SETFRAGMENT, &frag);
afmt = AFMT_S16_LE;
ioctl(afd, SNDCTL_DSP_SETFMT, &afmt);
if (afmt != AFMT_S16_LE) {
fprintf(stderr, "\n%s\n", "Can't get 16 bit DSP, exiting");
exit;
}
channels = 2;
ioctl(afd, SNDCTL_DSP_CHANNELS, &channels);
// sample rate
rate = 44100;
ioctl(afd, SNDCTL_DSP_SPEED, &rate);
if (-1 == ioctl(afd, SNDCTL_DSP_GETBLKSIZE, &blocksize)) {
fprintf(stderr, "\n%s\n", "Can't get DSP blocksize, exiting");
exit;
}
blocksize*=4; // allways read 4*blocksize
audio_buffer_size = blocksize;// This doesn't work!! Throws: Resource temporarily unavailable! // when reading.
// trigger record
trigger = ~PCM_ENABLE_INPUT;
ioctl(afd,SNDCTL_DSP_SETTRIGGER,&trigger);
trigger = PCM_ENABLE_INPUT;
ioctl(afd,SNDCTL_DSP_SETTRIGGER,&trigger);//
buffer = (char *)malloc(audio_buffer_size);
while(1) {
if (audio_buffer_size != (lastread = read(afd,buffer,audio_buffer_size)))
{
fprintf(stderr, "only read %d from %ld bytes from '%s'\n", lastread, audio_buffer_size,
audiodevice);
perror("read /dev*audiodevice");
if (lastread == -1)
exit (1);
}
else {
fprintf(stderr, ".");
write(ostr, buffer, audio_buffer_size);
}
}
} Quoted 3 lines · Pablo Baena
I'll focus on my actual configuration, so I can debug the problem. I have a SB16 Awe ISA, and I tried the OSS drivers with 2.6.0-test1. I have a VIAC686 motherboard, with a K7 650Mhz processor.
Right now you need the ALSA drivers for recording on VIA. Fixing the OSS one is down on the todo list somewhere but nobody has tackled it
Thanks! It would be good to have this well noticed somewhere. I spent days and days scratching my head, not knowing it is a well known issue.
Pablo
Quoted 7 lines · Alan Cox
Quoted 3 lines · Pablo Baena
I'll focus on my actual configuration, so I can debug the problem. I have a SB16 Awe ISA, and I tried the OSS drivers with 2.6.0-test1. I have a VIAC686 motherboard, with a K7 650Mhz processor.
Right now you need the ALSA drivers for recording on VIA. Fixing the OSS one is down on the todo list somewhere but nobody has tackled it
Signature · 1 line
Whip it, baby. Whip it right. Whip it, baby. Whip it all night!