From: Bankim Bhavsar <bankim.bhavsar@gmail.com>
To: alsa-devel@alsa-project.org, alsa-user@lists.sourceforge.net
Subject: Programming ALSA sound device.
Date: Thu, 16 Sep 2010 10:16:16 -0700 [thread overview]
Message-ID: <AANLkTikVq+q9uuprpCNZRB30-6LnaXEAe98xHm-gaA-Q@mail.gmail.com> (raw)
Producer thread writes sound bytes worth 10 ms every 10 ms to a ring buffer.
Consumer thread is responsible for writing sound bytes to ALSA sound
device in a strictly non-blocking fashion.
Consumer thread checks snd_pcm_avail/snd_pcm_avail_update, fetches
minimum of sound bytes available in ring buffer and
availFrames(returned by snd_pcm_avail_update) and writes to sound
device using snd_pcm_writei().
Consumer thread polls every 20 ms. However on consumer thread
snd_pcm_avail/snd_pcm_avail_update() returns 0 at least 3-4 times
consecutively (total 60-80 ms) and on every 5th-6th poll
snd_pcm_avail/snd_pcm_avail_update returns full buffer size
occasionally reporting an under-run. On an average, under-run is
reported at least 10-15 times a minute which is not desirable.
Following are the hardware and software parameter settings.
hardware params:
16-bit 44100 stereo
buffer time 200 ms
period time 25 ms
software params:
start_threshold: full buffer size
no setting for avail_min
Alternatively I've tried using wait_for_poll() technique as mentioned
in the example.
http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
However poll() unblocks very rapidly and producer ring buffer doesn't
have enough bytes.
What's the best technique for PCM playback for such use cases? Is it
okay to skip calling snd_pcm_avail/snd_pcm_avail_update and directly
attempt writing to ALSA sound device instead?
Let me know if more information is required.
Thanks,
Bankim.
next reply other threads:[~2010-09-16 17:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 17:16 Bankim Bhavsar [this message]
2010-09-17 8:15 ` Programming ALSA sound device Jaroslav Kysela
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=AANLkTikVq+q9uuprpCNZRB30-6LnaXEAe98xHm-gaA-Q@mail.gmail.com \
--to=bankim.bhavsar@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=alsa-user@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.