From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: When to start the capture device? Date: Thu, 20 Sep 2007 16:23:30 +0200 Message-ID: References: <005101c7fb13$511e5040$aea4c380@dream.eng.uci.edu> <20070920101427.2499dd58.alsauser@pragmasoft.com> 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 23B9D24448 for ; Thu, 20 Sep 2007 16:23:31 +0200 (CEST) In-Reply-To: <20070920101427.2499dd58.alsauser@pragmasoft.com> 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: "J. Scott Merritt" Cc: "Sheng (Sean) Liu" , alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 20 Sep 2007 10:14:27 -0400, J. Scott Merritt wrote: > > On Wed, 19 Sep 2007 16:17:55 -0700 > "Sheng \(Sean\) Liu" wrote: > > > > 1. The control point here the start threshold, which defines the number of > > frames of space/data necessary to start the device automatically. If set to > > some value other than zero for playback, it is necessary to prefill the > > playback buffer before the device will start. If set to zero, the first data > > written to the device (or first attempt to read from a capture stream) will > > start the device. > > > > My question: what does he means on " If set to zero"? Does anyone know which > > parameter of which API should be set to zero? > > I believe this would be snd_pcm_sw_params_set_start_threshold. > > > 2. You can also start the device explicitly using snd_pcm_start, but this > > requires buffer prefilling in the case of the playback stream. If you > > attempt to start the stream without doing this, you will get -EPIPE as a > > return code, indicating that there is no data waiting to deliver to the > > playback hardware buffer. > > > > My question: Is there anything to be done before calling snd_pcm_start in > > the case of capturing stream? If there is, what are they? > > I use: > snd_pcm_open > SetUpHwParams () ... /* lots of snd_pcm_hw_params_set ... calls */ > SetUpSwParams () ... /* lots of snd_pcm_sw_params_set ... calls */ > snd_pcm_prepare > snd_pcm_start snd_pcm_prepare() can be omitted in this case. After snd_pcm_hw_params(), the stream is set to PREPARED state. This isn't changed after snd_pcm_sw_params(), too. snd_pcm_prepare() is required to recover the stream from XRUN or any other errors. But, for the recovery purpose, we have now snd_pcm_recover() as a generic solution, too. Takashi