From: "Alfredo Rueda Unsain" <alfredo@vida-software.com>
To: alsa-devel@lists.sourceforge.net
Subject: Render audio data from a push source using event driven model
Date: Wed, 17 Aug 2005 20:53:32 +0200 [thread overview]
Message-ID: <web-708262@vida-software.com> (raw)
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
next reply other threads:[~2005-08-17 18:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-17 18:53 Alfredo Rueda Unsain [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-08-18 9:21 Render audio data from a push source using event driven model Alfredo Rueda Unsain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=web-708262@vida-software.com \
--to=alfredo@vida-software.com \
--cc=alsa-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.