From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Using snd_async_add_pcm_handler Date: Thu, 14 Oct 2004 17:15:20 +0200 Sender: alsa-devel-admin@lists.sourceforge.net Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Eric Ross Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 12 Oct 2004 22:02:25 -0300 (CLST), Eric Ross wrote: > > Hello there > > I've using ALSA to develop a little video player for the dillo browser, > also using the ffmpeg library. > > I based the audio part in the pcm.c example found in the library source, > but I have some questions about how alsa works. I'm using > SND_PCM_ACCESS_RW_INTERLEAVED access. > > Currently I'm using snd_async_add_pcm_handler to make ALSA call some > function when it needs data to play. I've read somewhere that before > calling snd_pcm_start() one need to feed some data into the buffer or I'll > get an error. So I have a call to snd_pcm_writei before calling > snd_pcm_start. The problem is that I cant figure out how much data I need > to write: in the pcm.c example, it does a loop to write 2*period_size > frames before calling _start(), so I do the same thing, but I'd like to > know the real reason (and make sure that my player will work in any > situation). It depends on the setting your app does. Usually for the playback (in so-called "push style" programming), the app feeds data as much as possible (= buffer_size as consequence) before starting, to be more robust for the scheduling latency. BTW, snd_async_add_pcm_handler() isn't recommended so much. If possible, use a dedicated thread for the audio processing, instead. > Also, I've ported the player to FamiliarLinux running in a IPaq, and it > runs ok without sound, but when starting to write data to alsa handler, I > just get a "Broken pipe" error. -EPIPE is the buffer xrun. The DMA is short of data. 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