From owner-freebsd-questions@FreeBSD.ORG Fri Aug 13 13:28:21 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BFA8616A4CE for ; Fri, 13 Aug 2004 13:28:21 +0000 (GMT) Received: from parallax.alastria.net (parallax.alastria.net [81.7.140.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id 086D643D1D for ; Fri, 13 Aug 2004 13:28:21 +0000 (GMT) (envelope-from peter@alastria.net) Received: from [10.2.0.1] (shuttle.cw9.co.uk [82.152.14.18]) i7DDSGHs038442 for ; Fri, 13 Aug 2004 13:28:16 GMT (envelope-from peter@alastria.net) Message-ID: <411CC1EF.5090201@alastria.net> Date: Fri, 13 Aug 2004 14:28:15 +0100 From: Peter Wood Organization: Alastria Networks User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Flag: NO X-Virus-Status: No X-Spam-Score: 0 () X-Spam-Ultra-Flag: NO X-Spam-Low-Flag: NO X-Spam-Flag: NO X-Spam-High-Flag: NO X-Scanned-By: MIMEDefang 2.42 Subject: FreeBSD pcm(4) latency (From write() to audible output) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2004 13:28:21 -0000 Moved from freebsd-chat: Quick addition: Had a look through the questions archive, nothing jumped out and answered this, but it's possible I missed something. 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) :: :: Tel +44 7974 799440