linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Sound recording problems
@ 2003-07-25 18:48 Pablo Baena
  2003-07-25 23:43 ` Alan Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Baena @ 2003-07-25 18:48 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

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!!
-- 
Whip it, baby. Whip it right. Whip it, baby. Whip it all night!

[-- Attachment #2: nrec.c --]
[-- Type: text/x-c, Size: 2426 bytes --]

// 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);
		}
	}
}                                                                                

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-26 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-25 18:48 Sound recording problems Pablo Baena
2003-07-25 23:43 ` Alan Cox
2003-07-26 14:42   ` Pablo Baena

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).