From: Takashi Iwai <tiwai@suse.de>
To: Giuliano Pochini <pochini@shiny.it>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Click after draining
Date: Tue, 19 Oct 2004 17:39:21 +0200 [thread overview]
Message-ID: <s5hekjuiuom.wl@alsa2.suse.de> (raw)
In-Reply-To: <XFMail.20041019170925.pochini@shiny.it>
At Tue, 19 Oct 2004 17:09:25 +0200 (CEST),
Giuliano Pochini wrote:
>
>
> On 19-Oct-2004 Takashi Iwai wrote:
>
> >> >> > The period size is always same even for the last period, AFAIK.
> >> >>
> >> >> Only if the driver explicitly asks for it by calling
> >> >> snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS).
> >> >
> >> > No, this means that buffer_size = N * period_size, where N is
> >> > integer. Without this constraint, N doesn't have to be an integer.
> >>
> >> Yes, exactly. If N isn't integer, the buffer is formed by
> >> bufsize\persize periods (== the integer part of N) plus one
> >> short period which is bufsize%persize long.
> >
> > The period size is constant regardless of N because it simply defines
> > the interval of interrupts. When N isn't integer (say, 2.5), the
> > transfer point moves like:
> >
> > 0, 1, 2, 0.5, 1.5, 0, 1, ...
> >
> > That is, when the point is at 2, the transfer is split to two parts
> > (2-2.5 and 0-0.5).
>
> Currently my driver uses a short period.
Well, then this is not a supported feature. period_size must be
constant in the current implementation.
> To fix it the
> driver should use a special feature of the DSP that allows
> the driver to build the s-g list on the fly. It also has
> the bonus that the DSP automatically stops the trasport
> when it reaches the last programmed period, so draining
> and xruns stop exactly where expected. It's more complex
> than the current ring buffer implementation.
>
> Out of curiosity, is there any driver that supports
> non-integer N ?
Yes, many drivers. As mentioned, the period_size is nothing but the
interrupt interval. On many chips, the interrupt interval is not
bound to the certain buffer positions.
> And why everything works fine even if the
> driver uses unequal periods ? It should skip all the time.
Maybe it has worked casually :)
In fact, period_size is referred rarely in the code.
Only snd_pcm_update_hw_ptr_interrupt() refers it, and changing
period_size only once per buffer isn't critical here since
hw_ptr_interrupt is corrected at each time from the last hw_ptr.
> Anyway, _fill_silence() can still overflow.
In your case, yes. But it's exceptional.
Usually, the DMA is stopped in the interrupt handler which processes
the last period. That is, the resolution of control is in the
interrupt interval (= period_size). This means that the whole period
data is transferred even if only the short data has been written to
the buffer.
Takashi
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
next prev parent reply other threads:[~2004-10-19 15:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-21 20:13 Click after draining Giuliano Pochini
2004-10-07 18:58 ` Giuliano Pochini
2004-10-08 15:34 ` Takashi Iwai
2004-10-08 16:07 ` Takashi Iwai
2004-10-08 20:26 ` Giuliano Pochini
2004-10-16 19:31 ` Giuliano Pochini
2004-10-18 11:14 ` Takashi Iwai
2004-10-18 14:56 ` Giuliano Pochini
2004-10-18 15:10 ` Takashi Iwai
2004-10-18 15:34 ` Giuliano Pochini
2004-10-19 11:03 ` Takashi Iwai
2004-10-19 15:09 ` Giuliano Pochini
2004-10-19 15:39 ` Takashi Iwai [this message]
2004-10-20 8:35 ` Giuliano Pochini
2004-10-20 9:38 ` Takashi Iwai
2004-11-01 19:29 ` Giuliano Pochini
2004-11-09 9:29 ` Takashi Iwai
2004-11-09 10:00 ` Giuliano Pochini
-- strict thread matches above, loose matches on Subject: below --
2007-01-05 22:48 Andrew Johnson
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=s5hekjuiuom.wl@alsa2.suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@lists.sourceforge.net \
--cc=pochini@shiny.it \
/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.