* ALSA and event notification schemas
@ 2005-07-25 17:09 Alfredo
2005-07-26 7:17 ` Clemens Ladisch
0 siblings, 1 reply; 4+ messages in thread
From: Alfredo @ 2005-07-25 17:09 UTC (permalink / raw)
To: alsa-devel@lists.sourceforge.net
[-- Attachment #1: Type: text/plain, Size: 1460 bytes --]
Hello, I'm involved in a development project consisting of a
multimedia/networked component using event driven model in a C++ Linux
environment (1 thread than manages all the events using an event loop).
The events that the component must handle are:
1. Sockets events.
2. Timer events.
3. Audio events ( event = when the next buffer is filled with audio from
the user, notify the component. Then the component will transfer the
audio buffer using a udp socket to another distributed component).
4. Key press and release events (Push To Talk key)
What is the best way to handle all this events in a Linux environment?
I have found that libevent is a very interesting library:
http://www.monkey.org/~provos/libevent/
"The libevent API provides a mechanism to execute a callback function
when a specific event occurs on a file descriptor or after a timeout has
been reached".
This resolves the sockets and timer events. I'm not sure if this
approach works well with ALSA (for audio events). I have read that ALSA
provides asynch IO (and callbacks mechanishm), but I don't know if it
fits well with libevent approach.
Is there any way use ALSA to handle audio events (like buffer is filled
with audio from the microphone) and handle the rest of the events in the
same process in a Linux environment?
Another question: Does ALSA support AMR or GSM codecs?
Your help is really very apreciated.
[-- Attachment #2: Type: text/html, Size: 4742 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: ALSA and event notification schemas
2005-07-25 17:09 ALSA and event notification schemas Alfredo
@ 2005-07-26 7:17 ` Clemens Ladisch
2005-07-26 8:47 ` Alfredo
0 siblings, 1 reply; 4+ messages in thread
From: Clemens Ladisch @ 2005-07-26 7:17 UTC (permalink / raw)
To: Alfredo; +Cc: alsa-devel
Alfredo wrote:
> Hello, I'm involved in a development project consisting of a
> multimedia/networked component using event driven model in a C++ Linux
> environment (1 thread than manages all the events using an event loop).
>
> The events that the component must handle are:
>
> 1. Sockets events.
>
> 2. Timer events.
>
> 3. Audio events ( event = when the next buffer is filled with audio from
> the user, notify the component. Then the component will transfer the
> audio buffer using a udp socket to another distributed component).
>
> 4. Key press and release events (Push To Talk key)
>
> What is the best way to handle all this events in a Linux environment?
poll()
> I have found that libevent is a very interesting library:
> http://www.monkey.org/~provos/libevent/
>
> "The libevent API provides a mechanism to execute a callback function
> when a specific event occurs on a file descriptor or after a timeout has
> been reached".
>
> This resolves the sockets and timer events. I'm not sure if this
> approach works well with ALSA (for audio events).
The above page says that libevent supports poll().
> Another question: Does ALSA support AMR or GSM codecs?
There is no such built-in codec.
HTH
Clemens
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: ALSA and event notification schemas
2005-07-26 7:17 ` Clemens Ladisch
@ 2005-07-26 8:47 ` Alfredo
2005-07-26 10:01 ` Alfredo
0 siblings, 1 reply; 4+ messages in thread
From: Alfredo @ 2005-07-26 8:47 UTC (permalink / raw)
To: alsa-devel@lists.sourceforge.net
Thank you for your answers.
I have studied Unix/Linux theory, and have a good knowledge base about
the underlaying principles of this kind of OS. The problem is that I
need some help in my first steps because I don't have a lot of practise.
I have read the manuals about ALSA, but have not found enough
information about the callback mechanism.
The way I must handle the audio is simple:
a) Play audio buffers that the component receives from the media network
protocol.
Using a simple prebuffering schema:
When I receive more or less 3 buffers start playing the audio
(Push approach).
The difficulty is that the audio buffers are encoded using AMR
or GSM format, so transcoding process is needed.
How can I implement this transcoding process in Linux/ALSA
environment?
In the other hand, I know that in other OS I don't have to worry
about event notifications when playing the audio. The media network
protocol handle the socket event and pushes the audio buffer to the
audio component. Then, the audio component uses a multimedia api to
prepare and play the audio buffer. The thread don't need to block and
don't have to worry about event notifications from the multimedia
library (assuming you drop the packets when buffers are full).
b) Record audio buffers from the microphone and transfer the buffers
using the media network protocol.
In this case is necessary to receive events notification. The
event is: "When the next buffer is filled with audio from the micro,
notify the thread. The thread awakes from the event loop to handle the
event: performs the encoding to AMR o GSM and then transmits the buffer
to the media network protocol.
Is there any way to implement such scenario in Linux/ALSA
environment?
Where can I find some code examples that use ALSA api in this
way?
I know that you suggested poll(), but I'm a bit lost ;-)
Sorry about the extension of the mail.
I need some feedback about my way of using the mailing list. These are
my first steps!
Thank you very much!
-----Original Message-----
From: aezr4@studcom.urz.uni-halle.de
[mailto:aezr4@studcom.urz.uni-halle.de] On Behalf Of Clemens Ladisch
Sent: martes, 26 de julio de 2005 8:17
To: Alfredo
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] ALSA and event notification schemas
Alfredo wrote:
> Hello, I'm involved in a development project consisting of a
> multimedia/networked component using event driven model in a C++ Linux
> environment (1 thread than manages all the events using an event
loop).
>
> The events that the component must handle are:
>
> 1. Sockets events.
>
> 2. Timer events.
>
> 3. Audio events ( event = when the next buffer is filled with audio
from
> the user, notify the component. Then the component will transfer the
> audio buffer using a udp socket to another distributed component).
>
> 4. Key press and release events (Push To Talk key)
>
> What is the best way to handle all this events in a Linux environment?
poll()
> I have found that libevent is a very interesting library:
> http://www.monkey.org/~provos/libevent/
>
> "The libevent API provides a mechanism to execute a callback function
> when a specific event occurs on a file descriptor or after a timeout
has
> been reached".
>
> This resolves the sockets and timer events. I'm not sure if this
> approach works well with ALSA (for audio events).
The above page says that libevent supports poll().
> Another question: Does ALSA support AMR or GSM codecs?
There is no such built-in codec.
HTH
Clemens
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: ALSA and event notification schemas
2005-07-26 8:47 ` Alfredo
@ 2005-07-26 10:01 ` Alfredo
0 siblings, 0 replies; 4+ messages in thread
From: Alfredo @ 2005-07-26 10:01 UTC (permalink / raw)
To: alsa-devel@lists.sourceforge.net
Hello! I have been reading poll manpage and interrupt driven example
program from an alsa manual at
http://equalarea.com/paul/alsa-audio.html#interruptex
//-----------------------------------------------------------
// This is a fragment of the code
(...)
while (1) {
/* wait till the interface is ready for data, or 1
second
has elapsed.
*/
if ((err = snd_pcm_wait (playback_handle, 1000)) < 0) {
fprintf (stderr, "poll failed (%s)\n", strerror
(errno));
break;
}
(...)
if (playback_callback (frames_to_deliver) !=
frames_to_deliver) {
fprintf (stderr, "playback callback
failed\n");
break;
}
}
//----------------------------------------------------------------------
I see, as you mention before, that snd_pcm_wait() uses poll() internally
to notify audio events.
If I want to use libevent (wich internally uses select or poll) as the
core of my event notification system, how can I know which file
descriptor represents the audio interface? In this example, snd_pcm_wait
is used, but I can't use this kind of api because the thread must handle
other kind of events.
Thank you very much for your support.
-----Original Message-----
From: Alfredo [mailto:alfredo@vida-software.com]
Sent: martes, 26 de julio de 2005 9:47
To: 'alsa-devel@lists.sourceforge.net'
Subject: RE: [Alsa-devel] ALSA and event notification schemas
Thank you for your answers.
I have studied Unix/Linux theory, and have a good knowledge base about
the underlaying principles of this kind of OS. The problem is that I
need some help in my first steps because I don't have a lot of practise.
I have read the manuals about ALSA, but have not found enough
information about the callback mechanism.
The way I must handle the audio is simple:
a) Play audio buffers that the component receives from the media network
protocol.
Using a simple prebuffering schema:
When I receive more or less 3 buffers start playing the audio
(Push approach).
The difficulty is that the audio buffers are encoded using AMR
or GSM format, so transcoding process is needed.
How can I implement this transcoding process in Linux/ALSA
environment?
In the other hand, I know that in other OS I don't have to worry
about event notifications when playing the audio. The media network
protocol handle the socket event and pushes the audio buffer to the
audio component. Then, the audio component uses a multimedia api to
prepare and play the audio buffer. The thread don't need to block and
don't have to worry about event notifications from the multimedia
library (assuming you drop the packets when buffers are full).
b) Record audio buffers from the microphone and transfer the buffers
using the media network protocol.
In this case is necessary to receive events notification. The
event is: "When the next buffer is filled with audio from the micro,
notify the thread. The thread awakes from the event loop to handle the
event: performs the encoding to AMR o GSM and then transmits the buffer
to the media network protocol.
Is there any way to implement such scenario in Linux/ALSA
environment?
Where can I find some code examples that use ALSA api in this
way?
I know that you suggested poll(), but I'm a bit lost ;-)
Sorry about the extension of the mail.
I need some feedback about my way of using the mailing list. These are
my first steps!
Thank you very much!
-----Original Message-----
From: aezr4@studcom.urz.uni-halle.de
[mailto:aezr4@studcom.urz.uni-halle.de] On Behalf Of Clemens Ladisch
Sent: martes, 26 de julio de 2005 8:17
To: Alfredo
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] ALSA and event notification schemas
Alfredo wrote:
> Hello, I'm involved in a development project consisting of a
> multimedia/networked component using event driven model in a C++ Linux
> environment (1 thread than manages all the events using an event
loop).
>
> The events that the component must handle are:
>
> 1. Sockets events.
>
> 2. Timer events.
>
> 3. Audio events ( event = when the next buffer is filled with audio
from
> the user, notify the component. Then the component will transfer the
> audio buffer using a udp socket to another distributed component).
>
> 4. Key press and release events (Push To Talk key)
>
> What is the best way to handle all this events in a Linux environment?
poll()
> I have found that libevent is a very interesting library:
> http://www.monkey.org/~provos/libevent/
>
> "The libevent API provides a mechanism to execute a callback function
> when a specific event occurs on a file descriptor or after a timeout
has
> been reached".
>
> This resolves the sockets and timer events. I'm not sure if this
> approach works well with ALSA (for audio events).
The above page says that libevent supports poll().
> Another question: Does ALSA support AMR or GSM codecs?
There is no such built-in codec.
HTH
Clemens
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id\x16492&op=click
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-07-26 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-25 17:09 ALSA and event notification schemas Alfredo
2005-07-26 7:17 ` Clemens Ladisch
2005-07-26 8:47 ` Alfredo
2005-07-26 10:01 ` Alfredo
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.