* Using snd_async_add_pcm_handler
@ 2004-10-13 1:02 Eric Ross
2004-10-14 15:15 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Eric Ross @ 2004-10-13 1:02 UTC (permalink / raw)
To: alsa-devel
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).
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.
Any sugestions ?
thanks in advance
PS: When running in the ipaq, the pcm_dump is:
Hardware PCM card 0 'H5xxx AK4535' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 16
buffer_size : 16384
period_size : 1024
period_time : 23219
tick_time : 10000
tstamp_mode : NONE
period_step : 1
sleep_min : 0
avail_min : 1024
xfer_align : 1
start_threshold : 16384
stop_threshold : 16384
silence_threshold: 0
silence_size : 0
boundary : 1073741824
--
#79989 counter.li.org
-------------------------------------------------------
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Using snd_async_add_pcm_handler
2004-10-13 1:02 Using snd_async_add_pcm_handler Eric Ross
@ 2004-10-14 15:15 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2004-10-14 15:15 UTC (permalink / raw)
To: Eric Ross; +Cc: alsa-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-14 15:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-13 1:02 Using snd_async_add_pcm_handler Eric Ross
2004-10-14 15:15 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox