Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#173514 - 03/08/2003 16:35 select()
753
member

Registered: 25/10/1999
Posts: 149
I'm at the end of my wits maybe someone here can push me in the right direction.
I'm playing with a small program that is supposed to record audio from /dev/dsp, which it doesn't. I've been digging through the source (not to find programming errors, the code is third party and supposed to be fine, but to locate the problem). We're doing a select(fd_audio+1, &reads, NULL, NULL, &time), and it always returns 0, no matter how loud I curse at my microphone.
Tracing back we did FD_SET(fd_audio, &reads); and fd_audio = open(dev_audio, O_RDONLY, 0) and dev_audio is /dev/dsp.
/dev/dsp is crw-rw--w- and the user belongs to the group audio. cat /dev/dsp actually shows output for the lightest tap on the mic, which makes me think that select should return 1.
Any ideas?
_________________________
_______ Thomas

Top
#173515 - 03/08/2003 17:00 Re: select() [Re: 753]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
What's time set to? It could be timing out?
If you're using Linux then time is modified after every call to select() so you must reinitialise it with whatever timeout you wanted. Not everybody does this so your code might only set timeout once.

Top
#173516 - 03/08/2003 17:26 Re: select() [Re: tman]
753
member

Registered: 25/10/1999
Posts: 149
Good point. I am using Linux and you were right the code only set time once to

struct timeval time;
time.tv_sec = 1;
time.tv_usec = 0;

I modified the code to reinitialize it before every select() call. Now I have select() returning 0 in 1 second intervals. Varying the timeout between 1 and 10 secs didn't help.

openAudio()
openAudio() is OK
Select() returns:0
Select() returns:0
Select() returns:0
Select() returns:0
Select() returns:0
...
_________________________
_______ Thomas

Top
#173517 - 03/08/2003 20:16 Re: select() [Re: 753]
tman
carpal tunnel

Registered: 24/12/2001
Posts: 5528
Ah okay. I've remember how to fix this. You must read some data before select works properly. A few bytes should do it.

Top
#173518 - 04/08/2003 07:10 Re: select() [Re: tman]
753
member

Registered: 25/10/1999
Posts: 149
That did the trick! I've now got incoming audio data. Thank you, Trevor.
_________________________
_______ Thomas

Top