alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Hofman <pavhofman@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Alsa-devel@alsa-project.org,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: Re: [alsa-devel] Measuring Device Throughput - MMAP vs. RW
Date: Mon, 9 Sep 2019 21:31:49 +0200	[thread overview]
Message-ID: <CA+SWvNw_=Fj_3M3sqVP767OOR+YDY=6-rPtPgmGXg+BcvuG3oA@mail.gmail.com> (raw)
In-Reply-To: <s5hzhjd9xg4.wl-tiwai@suse.de>

On Mon, Sep 9, 2019 at 7:44 PM Takashi Iwai <tiwai@suse.de> wrote:

> > The mmap fluctuations seem to be fixed by using increases in hardware
> > pointer pcm->hw.ptr values instead of frames variable. Please do these
> > values wrap up or do they grow  to max long? Still contiguous after 10
> > minutes of running.
>
> Could you elaborate the requirement?  The description isn't clear to
> me.
>

I need to slave EP OUT of asynchronous USB-audio gadget  (i.e. device) to
another (output) soundcard in the system so that adaptive resampling in the
chain "USB gadget -> processing -> output soundcard" is avoided.  For that
I need to measure average throughput to/from alsa hw:X devices, to gather
data for the feedback endpoint implemented by the gadget driver.  I do not
have any control over configuration of the devices, the feedback must run
independently of the rest of the chain, of the applications used.

In snd_pcm_hw_mmap_commit I subtract the advancement of pcm->hw.ptr from
value approx. 10 seconds ago, divided by passed nanosecs measured by
clock_gettime(CLOCK_MONOTONIC). For that I need the pcm->hw.ptr either to
be monotonic, or I just reset the averaging if a non-monotony is detected
(hw pointer in previous (n-1) call of snd_pcm_hw_mmap_commit was higher
than  current value).

For better precision, would it make sense to update the pcm->hw.ptr with
snd_pcm_avail call in that method? It may not be even possible in that
method due to some locking, I really do not know. But my precision
requirements are not very strict since I can average over long time
(minutes) for the feedback (the clock difference is usually very small).


>
> You should be able to skip XRUN check by changing the stop_threshold.
> Setting it to the boundary size essentially means skipping XRUN
> checks.
>

Actually if  xruns could be detected by discontinuity of the hw pointer, I
would not need any other method.


> In anyway, I put Pierre to Cc, as he's done some works in the past for
> the accurate position reporting on HD-audio and USB-audio devices.
> He can give a better hint in this regard.


Thanks a lot, I very much appreciate your help. I do not know these
low-level alsa details. But I will gladly learn.

Pavel.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2019-09-09 19:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-08 15:23 [alsa-devel] Measuring Device Throughput - MMAP vs. RW Pavel Hofman
2019-09-09 16:30 ` Pavel Hofman
2019-09-09 17:44   ` Takashi Iwai
2019-09-09 19:31     ` Pavel Hofman [this message]
2019-09-10  7:18       ` Takashi Iwai
2019-09-10  7:48         ` Pavel Hofman
2019-09-10  7:59           ` Pavel Hofman
2019-09-10 19:27           ` Pavel Hofman

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='CA+SWvNw_=Fj_3M3sqVP767OOR+YDY=6-rPtPgmGXg+BcvuG3oA@mail.gmail.com' \
    --to=pavhofman@gmail.com \
    --cc=Alsa-devel@alsa-project.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /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).