From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Click after draining Date: Tue, 19 Oct 2004 17:39:21 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Giuliano Pochini Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 19 Oct 2004 17:09:25 +0200 (CEST), Giuliano Pochini wrote: > > > On 19-Oct-2004 Takashi Iwai wrote: > > >> >> > The period size is always same even for the last period, AFAIK. > >> >> > >> >> Only if the driver explicitly asks for it by calling > >> >> snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS). > >> > > >> > No, this means that buffer_size = N * period_size, where N is > >> > integer. Without this constraint, N doesn't have to be an integer. > >> > >> Yes, exactly. If N isn't integer, the buffer is formed by > >> bufsize\persize periods (== the integer part of N) plus one > >> short period which is bufsize%persize long. > > > > The period size is constant regardless of N because it simply defines > > the interval of interrupts. When N isn't integer (say, 2.5), the > > transfer point moves like: > > > > 0, 1, 2, 0.5, 1.5, 0, 1, ... > > > > That is, when the point is at 2, the transfer is split to two parts > > (2-2.5 and 0-0.5). > > Currently my driver uses a short period. Well, then this is not a supported feature. period_size must be constant in the current implementation. > To fix it the > driver should use a special feature of the DSP that allows > the driver to build the s-g list on the fly. It also has > the bonus that the DSP automatically stops the trasport > when it reaches the last programmed period, so draining > and xruns stop exactly where expected. It's more complex > than the current ring buffer implementation. > > Out of curiosity, is there any driver that supports > non-integer N ? Yes, many drivers. As mentioned, the period_size is nothing but the interrupt interval. On many chips, the interrupt interval is not bound to the certain buffer positions. > And why everything works fine even if the > driver uses unequal periods ? It should skip all the time. Maybe it has worked casually :) In fact, period_size is referred rarely in the code. Only snd_pcm_update_hw_ptr_interrupt() refers it, and changing period_size only once per buffer isn't critical here since hw_ptr_interrupt is corrected at each time from the last hw_ptr. > Anyway, _fill_silence() can still overflow. In your case, yes. But it's exceptional. Usually, the DMA is stopped in the interrupt handler which processes the last period. That is, the resolution of control is in the interrupt interval (= period_size). This means that the whole period data is transferred even if only the short data has been written to the buffer. Takashi ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl