* Exemple of source code for capture without using callback
@ 2009-10-20 14:49 brunal2496 gmail
2009-10-22 14:40 ` James Courtier-Dutton
0 siblings, 1 reply; 5+ messages in thread
From: brunal2496 gmail @ 2009-10-20 14:49 UTC (permalink / raw)
To: alsa-devel
Hi all,
it's my first time on this list and my knowledge about using poll()
mutex and thread creation is a bit far away from now, so please, if
this list is the wrong place for such a question, could you point me
in the right direction?
Does anyone can point me a place to find a good exemple of source code
for capturing sound with alsa without using callbacks?
I'm trying to interface a voice recognition software with the alsa
drivers.
I have to get audio from alsa convert it and then send to the
recognition engine.
I've read everywhere that using callback is a bad method to use the
alsa drivers.
As the recognition software is a server, it needs to be synchronized
with my application. And so my main() cannot loop on a endless loop
with the snd_pcm_readi() function inside.
My first idea was to create a new thread and to let this thread
running with a endless loop that do the snd_pcm_readi() and send the
buffer to the recognition software.
But I 've read the existence of smd_pcm_poll_descriptors() function.
For now I not shure was it is for and how to use it properly.
What do you think?
I'm sorry if my question is a real newbie question, but exemple online
are only for playback not capture.
Many thanks for all your answers.
Bruno.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Exemple of source code for capture without using callback
2009-10-20 14:49 Exemple of source code for capture without using callback brunal2496 gmail
@ 2009-10-22 14:40 ` James Courtier-Dutton
2009-10-22 15:06 ` Clemens Ladisch
0 siblings, 1 reply; 5+ messages in thread
From: James Courtier-Dutton @ 2009-10-22 14:40 UTC (permalink / raw)
To: brunal2496 gmail; +Cc: alsa-devel
2009/10/20 brunal2496 gmail <brunal2496@gmail.com>:
>
> I'm trying to interface a voice recognition software with the alsa
> drivers.
>
> I have to get audio from alsa convert it and then send to the
> recognition engine.
> I've read everywhere that using callback is a bad method to use the
> alsa drivers.
>
This is wrong. callback is the best method.
With current distributions all doing pulseaudio, it would probably be
better interfacing with pulse.
If you need a more professional real time interface, use jackd interface.
For what you need, jackd is probably the simplest api to use.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Exemple of source code for capture without using callback
2009-10-22 14:40 ` James Courtier-Dutton
@ 2009-10-22 15:06 ` Clemens Ladisch
2009-10-22 19:47 ` James Courtier-Dutton
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2009-10-22 15:06 UTC (permalink / raw)
To: James Courtier-Dutton; +Cc: alsa-devel, brunal2496 gmail
James Courtier-Dutton wrote:
> 2009/10/20 brunal2496 gmail <brunal2496@gmail.com>:
> > I've read everywhere that using callback is a bad method to use the
> > alsa drivers.
>
> This is wrong. callback is the best method.
But _not_ the snd_async_add_pcm_handler function, which is evil.
(This is the only ALSA PCM function that mentions "callback" in its
documentation, so these are often confused.)
The 'good' callback method means that the audio driver informs the
application when its wants to have new audio data, not the other way.
Best regards,
Clemens
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Exemple of source code for capture without using callback
2009-10-22 15:06 ` Clemens Ladisch
@ 2009-10-22 19:47 ` James Courtier-Dutton
2009-10-23 9:39 ` brunal2496 gmail
0 siblings, 1 reply; 5+ messages in thread
From: James Courtier-Dutton @ 2009-10-22 19:47 UTC (permalink / raw)
To: Clemens Ladisch; +Cc: alsa-devel, brunal2496 gmail
2009/10/22 Clemens Ladisch <clemens@ladisch.de>:
> James Courtier-Dutton wrote:
>> 2009/10/20 brunal2496 gmail <brunal2496@gmail.com>:
>> > I've read everywhere that using callback is a bad method to use the
>> > alsa drivers.
>>
>> This is wrong. callback is the best method.
>
> But _not_ the snd_async_add_pcm_handler function, which is evil.
> (This is the only ALSA PCM function that mentions "callback" in its
> documentation, so these are often confused.)
>
> The 'good' callback method means that the audio driver informs the
> application when its wants to have new audio data, not the other way.
>
Yes, to clarify, not that call.
A poll() that then does the callback is the preferred method.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Exemple of source code for capture without using callback
2009-10-22 19:47 ` James Courtier-Dutton
@ 2009-10-23 9:39 ` brunal2496 gmail
0 siblings, 0 replies; 5+ messages in thread
From: brunal2496 gmail @ 2009-10-23 9:39 UTC (permalink / raw)
To: James Courtier-Dutton; +Cc: alsa-devel, Clemens Ladisch
Tanks for your answer.
>> But _not_ the snd_async_add_pcm_handler function, which is evil.
>> (This is the only ALSA PCM function that mentions "callback" in its
>> documentation, so these are often confused.)
>>
>> The 'good' callback method means that the audio driver informs the
>> application when its wants to have new audio data, not the other way.
If I'm not wrong you're talking about playback in that case, isn't it?
I'm considering capture so you mean that the good callback method is
when the audio driver tells the application that it have new audio
data (the buffer contains at least a "period_size" of audio samples)
to give to it. Am I right?
> Yes, to clarify, not that call.
> A poll() that then does the callback is the preferred method.
Ok. But I cannot find a source code using poll() for capture on
internet. Would you please gimme a pointer or at least a pseudo-code
for an application using poll() i.e. just what is the sequence of the
function?
Many thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-10-23 9:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-20 14:49 Exemple of source code for capture without using callback brunal2496 gmail
2009-10-22 14:40 ` James Courtier-Dutton
2009-10-22 15:06 ` Clemens Ladisch
2009-10-22 19:47 ` James Courtier-Dutton
2009-10-23 9:39 ` brunal2496 gmail
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.