From: Takashi Iwai Subject: Re: What does snd_pcm_delay() actually return? Date: Fri, 13 Jun 2008 08:59:53 +0200 Message-ID: References: <20080609190225.GA4534@tango.0pointer.de> <20080612205225.GB20818@tango.0pointer.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 34BE9243E3 for ; Fri, 13 Jun 2008 08:59:54 +0200 (CEST) In-Reply-To: <20080612205225.GB20818@tango.0pointer.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Lennart Poettering Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 12 Jun 2008 22:52:25 +0200, Lennart Poettering wrote: > > You didn't respond to my suggesion to add a second function, Hm, which function? I seem to have missed that. > so that > we'd have two: one that includes the extra delay after hw_ptr, and the > other that does not. The former would then be useful for audio/video > sync, the latter for estimating when an underrun will happen. Would it > be possible to add this? Indeed, there are two problems in the background: - the period irq model - no latency assumption The period irq model is what you called "traditional playback model". No latency assumption in hwptr comes from the PCI-style hardware. About the latency, my proposal is like below: - Renew the definition of hwptr -- make it what you imagned, the pointer where hardware is reading or has read. This won't change anything for PCI drivers, so the impact is minimal. - Add some new API functions, * To give the accuracy of the position inquiry (optional) This requires some new kernel <-> user-space stuff. * To query the known latency Ditto, or we may reuse snd_pcm_hw_params_fifo_size()? * To query the position being played (optionally) This can be simply hwptr + latency. - Don't change snd_pcm_delay(). Keep as is now. About the period model -- it's a bit more tough problem. I once already made a patch to allow user-apps to use a system timer for more flexible period settings. But, it was for very old version of ALSA. Better to write from the scratch again... Takashi