Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Eric Ross <eross+alsa-devel@disc.ucn.cl>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Using snd_async_add_pcm_handler
Date: Thu, 14 Oct 2004 17:15:20 +0200	[thread overview]
Message-ID: <s5h655dgwl3.wl@alsa2.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.61.0410122148530.26443@chacaya.disc.ucn.cl>

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

      reply	other threads:[~2004-10-14 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-13  1:02 Using snd_async_add_pcm_handler Eric Ross
2004-10-14 15:15 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5h655dgwl3.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=eross+alsa-devel@disc.ucn.cl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox