From: "Alexander E. Patrakov" <patrakov@gmail.com>
To: David Henningsson <david.henningsson@canonical.com>,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Takashi Iwai <tiwai@suse.de>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>
Subject: Re: Master Plan on rewinding
Date: Mon, 08 Sep 2014 14:46:54 +0600 [thread overview]
Message-ID: <540D6CFE.808@gmail.com> (raw)
In-Reply-To: <540D61C4.90206@canonical.com>
08.09.2014 13:59, David Henningsson wrote:
(First of all, a big thanks for being the first to talk constructively
about the important problem of rewindability classes!)
> On 2014-09-07 17:16, Alexander E. Patrakov wrote:
>> Hello.
>>
>> (TL;DR: nothing really new except the strawman proposal about threads
>> and the note about interaction of variable sample rate with
>> rewindability)
>
> So, having looked this through another time, it looks like we have three
> categories of ALSA devices, from rewindability point of view:
>
> 1) Not rewindable at all.
>
> 2) Rewindable down to the period size.
>
> 3) Rewindable even further than the nearest period, down to DMA
> transfer sizes or something else. This also requires the .pointer to
> have better granularity than the period size.
>
> So I think any is_seekable() call or flag should indicate whether the
> device is case 1), 2) or 3). And for case 3) perhaps also some indicator
> of the actual rewind granularity and/or safeguard. This should be enough
> for PA to be able to pick a suitable default latency.
So far, I agree. The big question now is: do we have enough correct data
from the kernel to decide between cases 2 and 3? I am definitely not
qualified enough to answer this or to add such interface, though.
> Case 1) is simple. Just let snd_pcm_rewindable return 0 and
> snd_pcm_rewind fail. If it doesn't, just fix it. (The extplug problem
> could be solved by PA having ifdefs depending on alsa-lib version,
> rather than making snd_pcm_rewind and snd_pcm_rewindable behave
> inconsistent.)
OK. But I don't think that the ifdef proposal is sufficient. If I
understand correctly, it only covers the "new PA on old alsa-lib"
problem, because we can't add these ifdefs to old PA. That's still
progress! But the "keep the old implementation of rewind" was for the
opposite problem - old PA on new alsa-lib which rightfully refuses to
rewind.
> For case 2) you seem to suggest to emulate case 3) by using either a
> low-latency thread, or by increasing the number of interrupts from the
> hardware. Either method will inevitably increase power consumption, and
> the former might also increase the risk of glitches. Therefore I think
> this is replacing something bad with something worse, because I would
> value low power consumption higher than better rewinding.
There is a slight misunderstanding above. I indeed proposed (and
retracted the proposal when I knew that it happens on mobile devices) to
emulate case 3 in case 2 by increasing the number of interrupts from the
hardware. The proposal of a low-latency background thread was about
emulating case 3 on case 1, and, so far, I have not retracted it, but I
may do so in the future.
As for power consumption increase, the argument is essentially a
duplicate of the phrase "the downside is that all programs (not only
those intending to do rewinds) now pay the cost of the background
low-latency thread" from my original mail. In other words, I partially
agree. This, if enabled unconditionally, indeed would lead to
unnecessary power consumption increase for those applications that don't
use rewinds. But for applications that want low latency or dynamic
latency, there is no other way to get it, so it is wrong to talk about
power consumption increase for such applications.
> Could we enable this functionality by explicit request by the
> application? Probably. E g, if the application sets a low period size
> but also sets the "disable period interrupts" flag, that could be an
> indicator that it wants lots of interrupts just to update the pointer,
> but nothing else. Maybe that's even the behaviour today (haven't checked).
A very good idea.
>
> The low-latency thread approach could be implemented by a separate
> ioplug layer, so that people who want it could open
> "flexiblerewind:plug:hw:0" instead of "plug:hw:0".
Also a good idea.
> However, with my PA hat on, I would still say no to having PA use either
> of those by default, for power consumption reasons.
I would also say no, but for a different reason (because, as I wrote
above, the power-consumption reason is valid only for software that
never wants to rewind and does not need low/dynamic latency, and PA does
not fall into this category). My argument is that, in the case of
PulseAudio, these emulations would just create an unnecessary layer of
complexity. PulseAudio actively wants to know the device type (via the
is_seekable() call), so it is reasonable for it to also deal with
consequences, without the need for additional processing in the driver
or for an extra thread.
> With that in mind I suggest, just as you, that we add
> .rewind/.rewindable callbacks to the ioplug layer. Any ioplug using
> .transfer needs to implement that if it wants to support rewinding,
> otherwise that ioplug would fall into category 1).
>
> Does that make sense? It was a long email, so I might have missed
> something. :-)
In fact, _I_ missed something when writing the original e-mail. I forgot
to address your phrase from
http://permalink.gmane.org/gmane.linux.alsa.devel/122191:
> I understand that you have a mathematically perfect approach to this, as
> well as other algorithms. This would indeed be the best goal, but given
> an imperfect world, where we're forced to choose between
> 1) no rewinding at all
> 2) imperfect rewinding in the sense that it sometimes can produce
> hearable artifacts
>
> ...I'm not sure 1) is always the right choice...
Should we have a snd_pcm_open (or whatever else) flag for accepting
imperfect rewind results? [anyway, I would say "no" to using it in
PulseAudio]
--
Alexander E. Patrakov
next prev parent reply other threads:[~2014-09-08 8:45 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-07 15:16 Master Plan on rewinding Alexander E. Patrakov
2014-09-07 18:38 ` Tanu Kaskinen
2014-09-07 19:05 ` Alexander E. Patrakov
2014-09-07 20:51 ` Clemens Ladisch
2014-09-08 3:06 ` Raymond Yau
2014-09-08 7:31 ` Alexander E. Patrakov
2014-09-09 8:43 ` Clemens Ladisch
2014-09-09 8:55 ` Alexander E. Patrakov
2014-09-09 9:08 ` David Henningsson
2014-09-09 9:31 ` Alexander E. Patrakov
2014-09-21 2:02 ` Raymond Yau
2014-09-22 13:20 ` Lars-Peter Clausen
2014-09-22 13:36 ` Alexander E. Patrakov
2014-09-22 13:44 ` Lars-Peter Clausen
2014-09-23 8:29 ` Raymond Yau
2014-09-23 10:22 ` Alexander E. Patrakov
2014-09-09 13:45 ` Clemens Ladisch
2014-09-09 15:55 ` Alexander E. Patrakov
2014-09-09 16:09 ` Takashi Iwai
2014-09-07 23:12 ` David Henningsson
2014-09-09 19:56 ` Pierre-Louis Bossart
2014-09-10 5:38 ` Alexander E. Patrakov
2014-09-08 7:34 ` Lars-Peter Clausen
2014-09-08 7:59 ` David Henningsson
2014-09-08 8:46 ` Alexander E. Patrakov [this message]
2014-09-08 9:26 ` David Henningsson
2014-09-08 10:21 ` Alexander E. Patrakov
2014-09-09 8:43 ` Clemens Ladisch
2014-09-11 3:49 ` Raymond Yau
2014-09-11 4:19 ` A. C. Censi
2014-09-13 9:15 ` Raymond Yau
2014-09-11 5:28 ` Alexander E. Patrakov
2014-09-11 6:21 ` Raymond Yau
2014-09-13 8:57 ` Raymond Yau
2014-09-13 10:43 ` Alexander E. Patrakov
2014-09-13 11:33 ` Raymond Yau
2014-09-13 11:36 ` Alexander E. Patrakov
2014-09-13 18:35 ` Alexander E. Patrakov
2014-09-14 11:37 ` Raymond Yau
2014-09-14 12:07 ` Alexander E. Patrakov
2014-09-15 2:43 ` Raymond Yau
2014-09-15 9:19 ` Takashi Iwai
2014-09-15 9:58 ` Alexander E. Patrakov
2014-09-15 10:08 ` Takashi Iwai
2014-09-15 17:01 ` Pierre-Louis Bossart
2014-09-15 17:14 ` Alexander E. Patrakov
2014-09-15 18:08 ` Takashi Iwai
2014-09-18 1:15 ` Raymond Yau
2014-09-21 9:22 ` Alexander E. Patrakov
2014-09-21 9:53 ` Clemens Ladisch
2014-09-21 10:56 ` Alexander E. Patrakov
2014-09-22 3:27 ` Raymond Yau
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=540D6CFE.808@gmail.com \
--to=patrakov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=david.henningsson@canonical.com \
--cc=o-takashi@sakamocchi.jp \
--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 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.