linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Baena <pbaena@uol.com.ar>
To: linux-kernel@vger.kernel.org
Subject: Sound recording problems
Date: 25 Jul 2003 18:48:19 +0000	[thread overview]
Message-ID: <1059158899.1116.29.camel@hal> (raw)

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

             reply	other threads:[~2003-07-25 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25 18:48 Pablo Baena [this message]
2003-07-25 23:43 ` Alan Cox
2003-07-26 14:42   ` Pablo Baena

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1059158899.1116.29.camel@hal \
    --to=pbaena@uol.com.ar \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: Sound recording problems' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).