Subject: Re: pkg/23571: Possible bug in audio drivers - request help with debugging
To: Michal Pasternak <michal@pasternak.w.lub.pl>
From: Andreas Gustafsson <gson@gson.org>
List: port-i386
Date: 11/25/2003 20:46:36
Michal Pasternak writes:
> On NetBSD-1.6.1 at the time of writing it is unable to read /dev/audio

Here is what I believe is happening.

They way the NetBSD audio device has always worked is that when you
open it, it starts out in the "recording paused" state.  It only starts
recording once you either explicitly unpause it using something like

	AUDIO_INITINFO(&info);
	info.record.pause = 0;
	int r = ioctl(fd, AUDIO_SETINFO, &info);

or, alternatively, when you when do a read() on it.

When accessing the audio device through a thread package, the read()
calls will be intercepted by the thread package and the actual read()
system call will only be invoked when select() (or poll()) indicates
that the device file descriptor is ready for reading; until that time,
the thread will be blocked.  Since recording is initially paused,
there will never be any data to read, select() never indicates a
"ready to read" condition, the real read() system call is never
actually called, and recording never starts.

This behavior has always struck me as odd, but I'm not entirely sure
whether it's a bug or just the correct implementation of a confusing
and insufficiently documented design.
-- 
Andreas Gustafsson, gson@gson.org