From mboxrd@z Thu Jan 1 00:00:00 1970 From: Clemens Ladisch Subject: Re: XRUN happens too often. Date: Thu, 10 Apr 2008 08:41:40 +0200 Message-ID: <47FDB6A4.7010704@ladisch.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by alsa0.perex.cz (Postfix) with ESMTP id CE84C243C2 for ; Thu, 10 Apr 2008 08:41:45 +0200 (CEST) In-Reply-To: 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: Rong-Jhe Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org Rong-Jhe wrote: > buffer size = 9408 frames > > A sample in 16-bit, two channels is 4 bytes. > I allocate a audio data of 9408x4=37632 bytes. > > audio_data=malloc(buffer_size*4); > > This audio_data buffer will receive audio data from the network. > If this buffer is full, I use snd_pcm_writei( ) to put the buffer into the pcm. When this buffer is full, the device buffer is completely empty, and even the slightest delay will result in an underrun. Write data to the device buffer immediately when you receive it. HTH Clemens