From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Click after draining Date: Mon, 18 Oct 2004 13:14:58 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: <20040921221318.4e0c7c7f.pochini@shiny.it> <20041007205801.6fb143ad.pochini@shiny.it> <20041016213113.1744f887.pochini@shiny.it> Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <20041016213113.1744f887.pochini@shiny.it> 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 Sat, 16 Oct 2004 21:31:13 +0200, Giuliano Pochini wrote: > > On Fri, 08 Oct 2004 18:07:53 +0200 > Takashi Iwai wrote: > > > > ALSA seems not putting silence properly unless silence_size > 0. > > > How about the attached patch? > > > (it's an untested and quick fix, as usual :) > > > > And broken, as usual :) > > The corrected on is below. > > The patch doesn't fix the problem. > > With your patch snd_pcm_do_drain_init() does: > > if (! runtime->silence_size) { > /* fill silence until the priod end */ > snd_pcm_uframes_t appl_ptr = runtime->control->appl_ptr; > snd_pcm_uframes_t delta = appl_ptr % runtime->period_size; > if (delta > 0) > snd_pcm_lib_fill_silence(substream, > appl_ptr % runtime->buffer_size, > runtime->period_size - delta); > } > > In my case delta is always 0. It seems ALSA aligns appl_ptr to the offset of > the next period without silencing the current one. If so, it has to be in alsa-lib. Not a bug of ALSA driver. > I could not find where. > Anyway, calling _fill_silence() with length=runtime->period_size - delta is > wrong IMHO because not all periods have have the same size. The last one can > be smaller and in that case it will overflow. The period size is always same even for the last period, AFAIK. > Also, I don't think filling with silence until the end of the period is > enough. ALSA stops the card some time it gets the interrupt, thus it should > silence also the subsequent period, or its beginning part. I thought of that, too, but concluded that it's a questionary behavior. Usually, it's not needed if the interrupt is taken fast enough at the moment the last period is processed. The click noise comes from the garbage data in the last period. Also, the app can specify silence_size if it needs this behavior explicitly. However, there can be a case that the irq isn't handled fast enough, or the DMA and the interrupt isn't synchronized well (e.g. using a timer interrupt because of lack of DMA interrupt). In such a case, auto-silencing would be needed for the proper work... 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