From: Kuninori Morimoto Subject: Re: Question about SNDRV_PCM_STATE_DRAINING and DMA transfer Date: Fri, 26 Sep 2014 01:45:37 -0700 (PDT) Message-ID: <87eguyn51t.wl%kuninori.morimoto.gx@gmail.com> References: <87wq8rm20r.wl%kuninori.morimoto.gx@gmail.com> <54251749.4040603@ladisch.de> <87lhp6n70k.wl%kuninori.morimoto.gx@gmail.com> <542520A7.6050604@perex.cz> 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 mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by alsa0.perex.cz (Postfix) with ESMTP id 36B13260489 for ; Fri, 26 Sep 2014 10:45:39 +0200 (CEST) Received: by mail-pd0-f182.google.com with SMTP id y10so641926pdj.27 for ; Fri, 26 Sep 2014 01:45:38 -0700 (PDT) In-Reply-To: <542520A7.6050604@perex.cz> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Jaroslav Kysela Cc: Linux-ALSA , Mark Brown , Clemens Ladisch , Kuninori Morimoto , "shiiba (Renesas)" List-Id: alsa-devel@alsa-project.org Hi Jaroslav > >>> We noticed that DMA seems transfered +1 time when Ctrl-C happen. > >>> But, is this correct ? is this our driver bug ? > >>> [...] > >>> 7. DMA transfer interrupt happen > >>> > >>> It calls snd_pcm_period_elapsed() and try to transfer next 2048 byte > >>> snd_pcm_playback_avail() in snd_pcm_update_state() return 8192 this time. > >>> then, it calls snd_pcm_drain_done() > >>> > >>> 9. snd_soc_dai_ops :: trigger called with SNDRV_PCM_TRIGGER_STOP > >>> > >>> driver stops DMA transfer > >> > >> There is no strong synchronization between snd_pcm_drain() and the rest > >> of the system; snd_pcm_drain() just waits for an underrun to happen. > >> > >> In other words, the last actual DMA transfer is likely to contain > >> invalid (outdated) samples, but gets aborted immediately. > > > > I wonder why we need drain ? > > This "likely to contain invalid samples" will be solved if > > we can skip "complete drain" ? > > The user app should do the flush instead the drain in this case... Thank you about this help. Can you show me how to do this in app side ? (Calling some alsa-lib function ?) Best regards --- Kuninori Morimoto