alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Underrun
@ 2011-03-01  5:59 Irfan Shaikh
  2011-03-01 13:42 ` Underrun Clemens Ladisch
  0 siblings, 1 reply; 2+ messages in thread
From: Irfan Shaikh @ 2011-03-01  5:59 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org, bahathir@gmail.com

Hello All,

A)     I am getting many under-run in my audio capture and playback application.

         1) My CAPTURE buffer is of 1024 * 8 (Period size * no of periods), PLAYBACK buffer is of (512 * 16)
         2) I try to read 8 K frames each time and write returned frames to playback device.
         3) Stereo audio, sample size 2 bytes, frame size 4 bytes, 48000 Hz

I have done following to reduce under run :
         1) Increased the number of periods on playback device (to increase playback latency).
         2) optimized my code

Please sugest me some more way so that i can avoid underrun of my playback device


B) Can i use snd_pcm_prepare() twice in two consecutive lines

For eg :
{
snd_pcm_prepare(pcm);
 snd_pcm_prepare(pcm);
}

        I just want to know if this is OK for playback device state.

Regards




SASKEN BUSINESS DISCLAIMER: This message may contain confidential, proprietary or legally privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Sasken Communication Technologies Limited ("Sasken") unless sent with that express intent and with due authority of Sasken. Sasken has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any 
 virus transmitted by this email.
Read Disclaimer at http://www.sasken.com/extras/mail_disclaimer.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Underrun
  2011-03-01  5:59 Underrun Irfan Shaikh
@ 2011-03-01 13:42 ` Clemens Ladisch
  0 siblings, 0 replies; 2+ messages in thread
From: Clemens Ladisch @ 2011-03-01 13:42 UTC (permalink / raw)
  To: Irfan Shaikh; +Cc: alsa-devel@alsa-project.org, bahathir@gmail.com

Irfan Shaikh wrote:
> I am getting many under-run in my audio capture and playback application.
> 
> 1) My CAPTURE buffer is of 1024 * 8 (Period size * no of periods), PLAYBACK buffer is of (512 * 16)
> 2) I try to read 8 K frames each time and write returned frames to playback device.

If you wait until the capture buffer is full, it's likely that you
get over/underruns at this moment.  You have to do the processing in
smaller chunks.

Typically, in loops like this, the normal state is that the capture
buffer is almost empty, and the playback buffer almost full.  You read
one period from the capture buffer (waiting for it if necessary),
process it, and write it to the playback buffer.  You need at least two
period per buffer so that one can be captured/played while the other one
is being processed, and maybe more periods as safety against delays.

> B) Can i use snd_pcm_prepare() twice in two consecutive lines

Yes (if the driver isn't buggy).

Regards,
Clemens


> SASKEN BUSINESS DISCLAIMER: ...

EVEN MORE IMPORTANT DISCLAIMER:
This e-mail contains public information intended for any subscriber of
this mailing list and for anybody else who bothers to read it; it will
be copied, disclosed and distributed to the public.  If you think you
are not the intended recipient, please commit suicide immediately.
These terms apply also to any e-mails quoted in, referenced from, or
answering this e-mail, and supersede any disclaimers in those e-mails.
Additionally, disclaimers in those e-mails will incur legal processing
fees of $42 per line; you have agreed to this by reading this disclaimer.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-01 13:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01  5:59 Underrun Irfan Shaikh
2011-03-01 13:42 ` Underrun Clemens Ladisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).