From: Rong-Jhe Subject: Re: XRUN happens too often. Date: Thu, 10 Apr 2008 07:59:06 +0000 (UTC) Message-ID: References: <47FB8D57.8030904@cox.net> <47FD42F2.70903@cox.net> <75b66ecd0804091801q1cf2d7fdq34a1b81048eb78d6@mail.gmail.com> <75b66ecd0804092154m47902330yd2772fef567554bc@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by alsa0.perex.cz (Postfix) with ESMTP id 46776103827 for ; Thu, 10 Apr 2008 09:59:16 +0200 (CEST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Jjrgg-0001Wo-Do for alsa-devel@alsa-project.org; Thu, 10 Apr 2008 07:59:15 +0000 Received: from 220.128.79.26 ([220.128.79.26]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Apr 2008 07:59:14 +0000 Received: from r93922118 by 220.128.79.26 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Apr 2008 07:59:14 +0000 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: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org > > ALSA does not generate threads for you like this. I was referring to > your application's audio thread, assuming that your app is indeed > multithreaded. > > The duration probably varies because the call to snd_pcm_writei() will > block until there is enough space in the ALSA ringbuffer to receive > your data. > > Lee > I found that there will be a thread generated after calling snd_pcm_open(). I use command 'ps' to check it. Due to this I guess snd_pcm_writei() only put the data into the buffer of the thread 'pcm'. This thread then schedules of mixes the audio data, and put it into the buffer of ALSA driver. ALSA ringbuffer only belongs to ALSA library, and ALSA driver uses anoother buffer in kernel. Thus, there must be a thread that can put the data in ALSA ringbuffer into the buffer of ALSA driver.