alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Raymond Yau <superquad.vortex2@gmail.com>
To: ALSA Development Mailing List <alsa-devel@alsa-project.org>
Subject: Re: "Resource temporarily unavailable" while reading although poll returns POLLIN event
Date: Mon, 26 Apr 2010 19:10:06 +0800	[thread overview]
Message-ID: <x2r4f3252891004260410gdd6f9f5ehc386c17d45aa9792@mail.gmail.com> (raw)
In-Reply-To: <4BD54C98.9050806@gmail.com>

2010/4/26 Stefan Schoenleitner <dev.c0debabe@gmail.com>

> Raymond Yau wrote:
> > Are you sure that you really need pulseaudio since your request latency
> is
> > quite low ?
>
> You mean the small period_size of 160 frames or rather the buffer size
> of 2*period_size?
>
> In fact at 8kHz sampling rate a period_size of 160 equals a full 20ms of
> sound:
>
> duration of one frame: 1000ms / 8000Hz = 0.125ms = 125 us
> 160 frames * 125us = 20000us = 20ms
>
> This is by far more than a large period size holds at a higher sampling
> rate (e.g. 44.1 kHz).
>

But the period time of your sound card is 40.634ms which is more than double
of your requested 20ms

D: alsa-util.c:   rate         : 44100
D: alsa-util.c:   exact rate   : 44100 (44100/1)
D: alsa-util.c:   msbits       : 16
D: alsa-util.c:   buffer_size  : 3584
D: alsa-util.c:   period_size  : 1792
D: alsa-util.c:   period_time  : 40634


>
> To the question whether pulseaudio is needed:
> On the embedded target PA will not be used, but since development takes
> place on a PC, I need a soundcard that supports the mentioned audio
> format contraints.
> And at the moment this is pulseaudio which is the reason why I really
> need it for application development.
>
>
> However, we should try to not drift away from the actual problem which
> is that *poll() returns an event even if far less than avail_min frames
> are available*.
>
>
> > You have to ask PA developer whether PA support such low latecny ?
> >
> > PA (tsched=0 ) configure your sound card 1792 frames per period but your
> > application request for 160 frames per period
> >
> > You will need the PA expert to answer how PA server capture 1792 frames
> from
> > sound card and send it to your application
> >
> > : module-alsa-source.c: Using 2 fragments of size 7168 bytes, buffer
> > time is 81.27ms
> >
> > D: alsa-util.c: Its setup is:
> > D: alsa-util.c:   stream       : CAPTURE
> > D: alsa-util.c:   access       : MMAP_INTERLEAVED
> > D: alsa-util.c:   format       : S16_LE
> > D: alsa-util.c:   subformat    : STD
> > D: alsa-util.c:   channels     : 2
> > D: alsa-util.c:   rate         : 44100
> > D: alsa-util.c:   exact rate   : 44100 (44100/1)
> > D: alsa-util.c:   msbits       : 16
> > D: alsa-util.c:   buffer_size  : 3584
> > D: alsa-util.c:   period_size  : 1792
> > D: alsa-util.c:   period_time  : 40634
> > D: alsa-util.c:   tstamp_mode  : ENABLE
> > D: alsa-util.c:   period_step  : 1
> > D: alsa-util.c:   avail_min    : 1792
> > D: alsa-util.c:   period_event : 0
> > D: alsa-util.c:   start_threshold  : -1
> > D: alsa-util.c:   stop_threshold   : 8070450532247928832
> > D: alsa-util.c:   silence_threshold: 0
> > D: alsa-util.c:   silence_size : 0
> > D: alsa-util.c:   boundary     : 8070450532247928832
>
> This is how pulseaudio works *internally*.
> Hence it opens my hardware sound card "hw" with the above format.
> If sound it recorded/played back at a different sampling rate, PA
> converts it.
> If you play a prerecorded audio file that has been recorded at a
> different sampling rate, you can see that behavior.
>

After the sound driver capture  40.634 ms of audio , PA have to convert the
44100Hz stereo to 8000Hz mono

seem just add left + right to mono without halve the sum , you may hear
clipping if you are using line in instead of mic or PA clamp the output

D: resampler.c: Channel matrix:
D: resampler.c:        I00   I01
D: resampler.c:     +------------
D: resampler.c: O00 | 1.000 1.000



> What happens is:
>
> [sound application (e.g.. aplay)] ---(audio format of sound file)---> [
> PA plugin] --> [PA daemon] ---(audio format of PA)--> [soundcard]
>
> cheers,
> stefan
>

  reply	other threads:[~2010-04-26 11:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21 11:28 "Resource temporarily unavailable" while reading although poll returns POLLIN event Stefan Schoenleitner
2010-04-21 16:15 ` Stefan Schoenleitner
2010-04-21 17:18   ` Jaroslav Kysela
2010-04-22 10:09     ` Stefan Schoenleitner
2010-04-23  4:10       ` Raymond Yau
2010-04-24  1:32       ` Raymond Yau
2010-04-24 14:38         ` Stefan Schoenleitner
2010-04-24 23:43           ` Raymond Yau
2010-04-26  7:52             ` Stefan Schoenleitner
2010-04-27  0:35               ` Raymond Yau
2010-04-26  1:46           ` Raymond Yau
2010-04-26  8:19             ` Stefan Schoenleitner
2010-04-26 11:10               ` Raymond Yau [this message]
2010-04-22  4:28   ` Raymond Yau
2010-04-22 10:49     ` Stefan Schoenleitner
2010-04-23  7:45       ` Raymond Yau
2010-04-23 11:16         ` Stefan Schoenleitner
2010-04-22  2:41 ` Raymond Yau
2010-04-22 10:15   ` Stefan Schoenleitner

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=x2r4f3252891004260410gdd6f9f5ehc386c17d45aa9792@mail.gmail.com \
    --to=superquad.vortex2@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /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 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).