Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Clemens Ladisch <clemens@ladisch.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: Re: For firewire drivers, reduce period time down to 2msec?
Date: Mon, 21 Apr 2014 22:28:31 +0200	[thread overview]
Message-ID: <53557F6F.8080701@ladisch.de> (raw)
In-Reply-To: <5355033F.7060606@sakamocchi.jp>

Takashi Sakamoto wrote:
> Currently I'm working for next patchsets and I'll post them in Friday.

I should be healthy again by then.

> The patchset also includes my idea to apply common PCM hw constraints to
> dice/speakers(oxfw)/fireworks/bebob. Currently the constraints includes:
> 1.Maximum bits for PCM sample is limited by 24.
> 2.Minimum time for period is currently 2msec.
> 3.In blocking mode, frames per period/buffer is aligned to SYT_INTERVAL
>
> I think you'll agree with 1 and 3.

Yes.

> So I want to discuss the second one beforehand.
>
> Currently dice/speakers driver apply 5msec for period time.

This is just because of the fixed INTERRUPT_INTERVAL, plus lots of
safety margin to reduce the relative jitter of the period interrupt.
(If the interrupt interval were dynamic, it should be possible to
reduce periods to about 0.25 ms.)

> I want to reduce this to 2msec. The reason of this '2msec' is:
>  - Currently firewire-lib process 16 packets in one time.
>  - This equals to 2msec (= INTERRUPT_INTERVAL / 8000 * 1000)
>  - During this 2msec, when pcm_period_pointer passes through period
> boundary, snd_pcm_period_elapsed() is scheduled with tasklet.
>  - But tasklet can execute one time even if the function is scheduled
> several times before executing it.
>  - The packetizing process is enough fast so the function can be
> scheduled before executing.
>  - As a result, snd_pcm_period_elapsed() can be called one time every 2msec.
>
> Actually my devices can work fine with period == 2msec or less than
> 5msec, without any disadvantage.

ALSA actually uses a fixed period _size_.  When the period length is set
to exactly 2 ms, but the 16 packets between two FireWire interrupts
contain one sample less than needed, the ALSA period interupt is delayed
until the next FireWire interrupt.  In that case, Jack with two periods
is likely to underrun.

The minimum time should be increased so that at least one FireWire
interrupt is guaranteed to happen for each period, even when there are
rounding errors and clock differences.


Regards,
Clemens

       reply	other threads:[~2014-04-21 20:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <5355033F.7060606@sakamocchi.jp>
2014-04-21 20:28 ` Clemens Ladisch [this message]
2014-04-22 13:24   ` For firewire drivers, reduce period time down to 2msec? Takashi Sakamoto

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=53557F6F.8080701@ladisch.de \
    --to=clemens@ladisch.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=o-takashi@sakamocchi.jp \
    /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