From owner-freebsd-questions@FreeBSD.ORG Fri Aug 13 15:11:28 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 3F3EB16A4CE for ; Fri, 13 Aug 2004 15:11:28 +0000 (GMT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6150143D2D for ; Fri, 13 Aug 2004 15:11:27 +0000 (GMT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.11/8.12.11) id i7DFBJIq097912; Fri, 13 Aug 2004 10:11:19 -0500 (CDT) (envelope-from dan) Date: Fri, 13 Aug 2004 10:11:19 -0500 From: Dan Nelson To: Peter Wood Message-ID: <20040813151119.GE4198@dan.emsphone.com> References: <411CC1EF.5090201@alastria.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <411CC1EF.5090201@alastria.net> X-OS: FreeBSD 5.2-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.6i cc: freebsd-questions@freebsd.org Subject: Re: 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 15:11:28 -0000 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 hw.snd.targetirqrate. -- Dan Nelson dnelson@allantgroup.com