[alsa-devel] capturing data from the microphone

Riccardo Magliocchetti riccardo.magliocchetti at gmail.com
Thu Jan 7 19:34:34 CET 2010

Raymond Yau ha scritto:
> 2010/1/6 Riccardo Magliocchetti <riccardo.magliocchetti at gmail.com>
>> Hi Pierre,
>> pl bossart ha scritto:
>>> You haven't specified the buffer/period size in the hw params. See
>>> alsa-lib/test/pcm.c
>>> - Pierre
>> They fail when opening default device so I had to remove them, work fine
>> when opening
>> plughw:0,0 though.
>>> On Mon, Jan 4, 2010 at 11:39 AM, Riccardo Magliocchetti
>>> <riccardo.magliocchetti at gmail.com> wrote:
>>>> [the same message is waiting in moderator queue, sorry if you receive it
>> two times]
>>>> Hello,
>>>> i'm trying to capture audio data from the microphone, but i'm not able
>> to
>>>> read any frames.
>>>> The frames are always 0 and delay is fixed to 2730. I've tried calling
>>>> snd_pcm_avail_delay,  snd_pcm_avail_update but does not make a
>> difference.
>>>> The soundcard is driven by  snd_hda_intel. The code is more or less the
>>>> same as Paul Davis' tutorial on using the alsa api.

> Even 4096 bytes is x86 DMA page size , seem to be a good choice for those
> PCI sound cards, however you cannot assume all sound cards/plugins support
> this buffer size
> If you did not set period_size, buffer_size or periods (period_time,
> buffer_time or periods)  , you should call
> snd_pcm_hw_params_get_buffer_size() and snd_pcm_hw_params_get_period_size()
> after snd_pcm_hw_params()

Thank you both Pierre and Raymond, using the get functions after snd_pcm_hw_params() is 
working, now i have some concurrency issues to resolve before i can say everything is 
working properly.

Thanks again,

More information about the Alsa-devel mailing list