[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FreeBSD pcm(4) latency (From write() to audible output)

In the last episode (Aug 13), Peter Wood said:
> 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 ;).

What's your write size?  At 44100khz*2 channels, a 65k write would take
around 800 ms to play.  Try writing smaller chunks, or maybe raise

	Dan Nelson