Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Aug 2004 12:03:05 +0100
From:      Peter Wood <peter@alastria.net>
To:        freebsd-chat@freebsd.org
Subject:   FreeBSD pcm(4) latency (From write() to audible output)
Message-ID:  <411C9FE9.3000905@alastria.net>

next in thread | raw e-mail | index | archive | help
Good Morning,

I'm currently in the middle of writing an automated radio playout system 
for a northern student radio station in the UK (post SBN liquidation).

I have the requirement of it running on a *nix system. I'm a large BSD 
advocate between our friends, so would prefer not to use Linux.

The system design consists of a daemon for each soundcard used in the 
studio. I'm currently in the process of writing this daemon.

I've found that there is about a 800ms delay between the output data 
being written to /dev/dsp and being able to hear the output from the 
soundcard on FreeBSD. I'm working to a 200ms deadline.

I'm opening the soundcard with:

audio_fd = open((char *) device, O_WRONLY | O_FSYNC | O_DIRECT);

I've used O_DIRECT and O_FSYNC to try and get rid of this delay, but 
alas that didn't work, device is cast as it's coming from a void * 
(thanks to pthread_create ;).

The daemon outputs blocks of 0 when there is no actual audio to output 
so the sound card is always fed.

While this isn't a problem for mpg123, it is for this application.  I've 
tried to find where the delay is, however I haven't had any luck.

Could anyone knowledgable let me know if there's any hope for getting 
rid of it (hacking the kernel is fine ;) or if I should "give up" and go 
to linux?

I suppose Linux does have ALSA which claims 2.6ms latency but I was 
hoping to just use OSS. Oh well.

For reference the test machine is a 2.2Ghz machine with a AC97 chip 
(yeah crap I know, studio playout machines will probably have a Creative 
card) running 4.10-STABLE (Yeasturday's cvsup).

My appologies if this isn't the right place, I'm happy to go pester else 
where. Heh.

Many thanks,

Pete.
-- 
Peter Wood BSc (Hons) :: <peter@alastria.net> :: Tel +44 7974 799440



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?411C9FE9.3000905>