From: "Alexander E. Patrakov" <patrakov@gmail.com>
To: Raymond Yau <superquad.vortex2@gmail.com>
Cc: ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Clemens Ladisch <clemens@ladisch.de>,
David Henningsson <david.henningsson@canonical.com>
Subject: Re: On non-rewindability of resamplers
Date: Sat, 26 Apr 2014 16:01:08 +0600 [thread overview]
Message-ID: <535B83E4.5050303@gmail.com> (raw)
In-Reply-To: <CAN8ccibLsqb6oxai=+XOAhZ1dPwZmVVD2r3teDsz2a2_CthoOA@mail.gmail.com>
26.04.2014 07:32, Raymond Yau wrote:
> 2014-04-25 22:09 GMT+08:00 Alexander E. Patrakov <patrakov@gmail.com
> <mailto:patrakov@gmail.com>>:
>
> 25.04.2014 12:19, David Henningsson wrote:
>
> 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...
>
>
> Understood. But IMHO (2) with a warning would be better than the
> current situation of (2) without any indication of the problem.
>
>
> Does extplug or ioplug plugin support rewind ?
>
> http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_external_plugins.html
>
Both plugins currently pretend to support rewind. Extplug shouldn't do
that at all if we are talking about perfect handling of rewinds, and is
OK as it is if we accept an imperfect output of the correct length (but
I don't want to accept this). Ioplug shouldn't support rewind if mmap_rw
== 0, and I can't say yet what to do with mmap_rw == 1. Running the test
program posted earlier in this thread on top of lfloat + jack produces
silence (good!), but, depending on the jack settings, the program either
hangs or runs faster than it should. So still a bug, but I am not sure
if it is of some fundamental nature.
> 1) DCA plugin convert 6 channel to compress audio at fixed sample rate
>
> seem only allow sequential write and no random write
>
Right. The same applies to any LADSPA plugin.
Still, there is a funny thing that I want to share. Even though the
dcaenc library only allows sequential writes, here is what happens on
ALSA rewind followed by a write. When processing a rewind, extplug moves
the slave application pointer. Upon reveiving a write, extplug submits
the newly-written data for encoding, and then writes the result (which
unfortunately contains some samples from the rewound part of the sound)
over the previously encoded data, thus correctly discarding part of the
old data. So the end result is of the correct length, with one or two
broken DTS frames (copy-pasted from old and new DTS data) in the middle.
Still bad, but this is different from the ioplug-based a52 plugin, which
simply ignores rewinds, but pretends that it succeeds.
> 2) The I/O-type plugin is a PCM plugin to work as the input or output
> terminal point, i.e. as a user-space PCM driver.
>
> mmap_rw specifies whether the plugin behaves in the pseudo mmap mode.
> When this value is set to 1, the plugin creates always a local buffer
> and performs read/write calls using this buffer as if it's mmapped.
>
> does this mean ioplug can have its own local buffer which is different
> from the slave ?
>
Ioplug doesn't have a slave. It just transfers data to somewhere.
> e.g. a52_pointer seem use delay of the slave
>
What a52 has is not really a slave in the traditional ALSA sense. And
the encoder in ffmpeg allows only sequential writes.
> 3) Do pulseaudio keep a copy of client 's buffer ?
>
> when do pulseauido mix two or more client's buffer ( before write to
> the sound card or after receive data from client )
>
> seem pulse plugin is not rewindable too
>
That's a limitation of the pulse plugin, originating from ioplug design.
The pulse API does allow rewinds (see the last two parameters of
pa_stream_write), but ioplug with mmap_rw = 0 essentially ignores ALSA
rewinds, i.e. it is impossible to know in alsa-plugins/pulse/*.c that a
rewind has to be processed.
--
Alexander E. Patrakov
next prev parent reply other threads:[~2014-04-26 10:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-22 17:41 Testing rewindability of a pcm Alexander E. Patrakov
2014-04-24 12:00 ` Clemens Ladisch
2014-04-24 21:01 ` On non-rewindability of resamplers (was: Testing rewindability of a pcm) Alexander E. Patrakov
2014-04-25 6:19 ` On non-rewindability of resamplers David Henningsson
2014-04-25 14:09 ` Alexander E. Patrakov
2014-04-26 1:32 ` Raymond Yau
2014-04-26 10:01 ` Alexander E. Patrakov [this message]
2014-04-28 6:57 ` Raymond Yau
2014-04-28 17:31 ` Alexander E. Patrakov
2014-04-29 16:01 ` Raymond Yau
2014-04-29 17:17 ` Alexander E. Patrakov
2014-04-29 17:33 ` Alexander E. Patrakov
2014-05-02 5:39 ` Raymond Yau
2014-05-03 11:09 ` Alexander E. Patrakov
2014-05-10 0:46 ` Raymond Yau
2014-05-10 13:16 ` Alexander E. Patrakov
2014-05-12 3:11 ` Raymond Yau
2014-05-12 4:52 ` Alexander E. Patrakov
2014-05-13 17:21 ` Alexander E. Patrakov
2014-05-23 2:03 ` Raymond Yau
2014-05-23 18:59 ` Alexander E. Patrakov
2014-05-24 5:10 ` Raymond Yau
2014-05-24 7:31 ` Alexander E. Patrakov
2014-05-30 0:59 ` Raymond Yau
2014-05-28 7:58 ` Raymond Yau
2014-05-28 15:38 ` Alexander E. Patrakov
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=535B83E4.5050303@gmail.com \
--to=patrakov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=david.henningsson@canonical.com \
--cc=superquad.vortex2@gmail.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 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).