* Render audio data from a push source using event driven model
@ 2005-08-17 18:53 Alfredo Rueda Unsain
0 siblings, 0 replies; 2+ messages in thread
From: Alfredo Rueda Unsain @ 2005-08-17 18:53 UTC (permalink / raw)
To: alsa-devel
Hello!
I'm developing a Linux server that use poll as the event
notification schema.
The server must render audio that receives from a push
source in real time.
When I receive a UDP Datagram (audio packet) I must render
the packet using write in NON BLOCKING mode.
I have read all the ALSA documentation (including the
examples) but I'm not sure how to proceed. The examples
that use poll, use the snd_pcm_sw_params_set_avail_min
function to specify when they want to be notified in order
to write audio samples without blocking.
In this sense I could use the following schema:
When I receive an audio packet, store the packet in a FIFO
queue.
Use snd_pcm_sw_params_set_avail_min to specify the number
of samples of an audio packet.
When ALSA notifies the server, consume the next packet
from the FIFO and write the packet.
I'm using another approach:
1. Open the PCM device (with SND_PCM_NONBLOCK flag).
2. Setup the PCM device (using
snd_pcm_sw_params_set_start_threshold to prefetch 3
packets).
3. Prepare the PCM device. (What is the purpose of
snd_pcm_prepare function?
I have read the states of a PCM device but, don't
understand the changes between
SETUP and PREPARED states).
4. When I receive an audio packet:
a) If there is enough space in the audio buffer, render
the packet directly using snd_pcm_writei.
b) else, drop the packet.
The problem is that before calling snd_pcm_writei, I
call snd_pcm_avail_update and returns only 336 samples to
deliver (only 1 channel).
The examples show that event driven programs must use
snd_pcm_sw_params_set_avail_min,
but I don't understant why snd_pcm_avail_update
returns only 336 samples if I call snd_pcm_prepare a lot
of seconds before.
What is the right approach to proceed in this
scenario?
Thank you very much for your help.
Alfredo Rueda.
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 2+ messages in thread
* Render audio data from a push source using event driven model
@ 2005-08-18 9:21 Alfredo Rueda Unsain
0 siblings, 0 replies; 2+ messages in thread
From: Alfredo Rueda Unsain @ 2005-08-18 9:21 UTC (permalink / raw)
To: alsa-devel
Hello!
I'm developing a Linux server that use poll as the event
notification schema.
The server must render audio that receives from a push
source in real time.
When I receive a UDP Datagram (audio packet) I must render
the packet using write in NON BLOCKING mode.
I have read all the ALSA documentation (including the
examples) but I'm not sure how to proceed. The examples
that use poll, use the snd_pcm_sw_params_set_avail_min
function to specify when they want to be notified in order
to write audio samples without blocking.
In this sense I could use the following schema:
When I receive an audio packet, store the packet in a FIFO
queue.
Use snd_pcm_sw_params_set_avail_min to specify the number
of samples of an audio packet.
When ALSA notifies the server, consume the next packet
from the FIFO and write the packet.
I'm using another approach:
1. Open the PCM device (with SND_PCM_NONBLOCK flag).
2. Setup the PCM device (using
snd_pcm_sw_params_set_start_threshold to prefetch 3
packets).
3. Prepare the PCM device. (What is the purpose of
snd_pcm_prepare function?
I have read the states of a PCM device but, don't
understand the changes between
SETUP and PREPARED states).
4. When I receive an audio packet:
a) If there is enough space in the audio buffer, render
the packet directly using snd_pcm_writei.
b) else, drop the packet.
The problem is that before calling snd_pcm_writei, I
call snd_pcm_avail_update and returns only 336 samples to
deliver (only 1 channel).
The examples show that event driven programs must use
snd_pcm_sw_params_set_avail_min,
but I don't understant why snd_pcm_avail_update
returns only 336 samples if I call snd_pcm_prepare a lot
of seconds before.
What is the right approach to proceed in this
scenario?
Thank you very much for your help.
Alfredo Rueda.
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-08-18 9:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-18 9:21 Render audio data from a push source using event driven model Alfredo Rueda Unsain
-- strict thread matches above, loose matches on Subject: below --
2005-08-17 18:53 Alfredo Rueda Unsain
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.