All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Stefano Antonelli <santonelli@algosolutions.com>,
	alsa-devel@alsa-project.org
Subject: Re: plughw behaviour not consistent with hw
Date: Tue, 6 Nov 2018 16:52:43 +0900	[thread overview]
Message-ID: <04a1fb10-323e-3dfa-6950-20912df97f75@sakamocchi.jp> (raw)
In-Reply-To: <1541047452.26732.263.camel@algosolutions.com>

Hi,

On 2018/11/01 13:44, Stefano Antonelli wrote:
> Does anyone know why plughw might be acting the way it is and how I can
> get it to deliver 10ms periods?  Equally appreciated would be any tips
> on how to debug this problem.

The 'plughw' PCM node of alsa-lib configuration space is assigned to
'plug' PCM plugin[1]. This PCM plugin can aggregate several PCM plugins
to perform resampling. For example, in a below case, two PCM plugins
(rate/route conversion PCM plugins) are aggregated by 'plug' PCM plugin
in front of 'hw' PCM plugin which direct accesses to ALSA PCM chracter
device.

$ LC_ALL=C arecord -v -Dplughw:1,0 /dev/null -fS16_LE
Recording WAVE '/dev/null' : Signed 16 bit Little Endian, Rate 8000 Hz, Mono
Plug PCM: Rate conversion PCM (48000, sformat=S16_LE)
Converter: libspeex (external)
Protocol version: 10002
Its setup is:
   stream       : CAPTURE
   access       : RW_INTERLEAVED
   format       : S16_LE
   ...
Slave: Route conversion PCM (sformat=S16_LE)
   Transformation table:
     0 <- 0*0.5 + 1*0.5
Its setup is:
   stream       : CAPTURE
   access       : MMAP_INTERLEAVED
   format       : S16_LE
   ...
Slave: Hardware PCM card 1 'HDA Intel PCH' device 0 subdevice 0
Its setup is:
   stream       : CAPTURE
   access       : MMAP_INTERLEAVED
   format       : S16_LE
   ...


Well, for capture direction, the most of PCM plugins in
alsa-lib/alsa-utils are programmed to do resampling in .avail_update()
callback of plugin framework in alsa-lib. The number of available PCM
frames is calculated in this timing. On the other hand, poll(2) system
call is executed against ALSA PCM character device. Even if poll(2)
returns to notify available PCM frames in the device, actual number of
available frames is a summary of resampling done by the
aggregated PCM plugins. As a result, you can see the behaviour because
plugins possibly have buffers for count gap between in/out frames.

[1] 
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/conf/alsa.conf;h=bb00ff409cd9643b01e2d3f8e36dc9571ddb0c85;hb=HEAD#l193


Regards

Takashi Sakamoto
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

      reply	other threads:[~2018-11-06  7:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  4:44 plughw behaviour not consistent with hw Stefano Antonelli
2018-11-06  7:52 ` Takashi Sakamoto [this message]

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=04a1fb10-323e-3dfa-6950-20912df97f75@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=santonelli@algosolutions.com \
    /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.