From: "Alexander E. Patrakov" <patrakov@gmail.com>
To: David Henningsson <david.henningsson@canonical.com>,
Clemens Ladisch <clemens@ladisch.de>,
alsa-devel@alsa-project.org
Subject: Re: On non-rewindability of resamplers
Date: Fri, 25 Apr 2014 20:09:26 +0600 [thread overview]
Message-ID: <535A6C96.7040109@gmail.com> (raw)
In-Reply-To: <5359FE72.8050605@canonical.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.
>> int snd_pcm_hw_params_is_seekable(const snd_pcm_hw_params_t *params);
>>
>> Check if the device fully supports rewinds and forwards.
>>
>> Parameters:
>> params Configuration space
>>
>> Return values:
>> 0 The whole plugin chain is not guaranteed to support arbitrary
>> rewinds and forwards.
>> 1 The whole plugin chain is guaranteed, under all remaining
>> configurations in the configuration space, to support any rewinds and
>> forwards that don't move the application pointer through the hardware
>> pointer.
>>
>> If this function is called when there is more than one configuration
>> exists in the configuration set (e.g. when the rate is not fixed), it
>> may return pessimistic results.
>
> I wonder if this is flexible enough. I think it would be not too
> uncommon for hardware drivers to e g transfer data to the hardware one
> period at a time. Hence what would make sense to rewind could be
> everything but the current period. A similar approach could potentially
> be done with resamplers (save state data every period so you can rewind
> correctly to exactly those points but nowhere else).
>
> This would be good to indicate somehow. I e, I'd like to see
> snd_pcm_rewindable take into account how much actually makes sense to
> rewind, taking DMA buffer sizes and other things into account where
> appropriate. Today, we add our own margin of 1.33 ms in PulseAudio
> because (if my understanding is correct) "some DMAs don't like us
> writing exactly the block it's busy transferring", but it would be
> better if this was indicated by ALSA.
This looks like two valid feature requests. Regarding the limited
flexibility, this can be solved by returning a bitmask of rewind-related
limitations, but the current hw_params API doesn't have any functions
that return bitmasks. Instead, for each new problem, a new function is
created. So it may make sense to create more than one function. However,
I am afraid to create a duplicate of an existing function. Does anyone
know whether the "must not rewind to the current period" limitation is
the same as already indicated by snd_pcm_hw_params_get_fifo_size() or
snd_pcm_hw_params_is_batch() or snd_pcm_hw_params_is_block_transfer()?
Of course, these limitations should be honoured by snd_pcm_rewindable().
As for the applicability of limiting the rewinds to the period
boundaries (where the resampler state is saved), then we have already
discussed something similar in person during LinuxCon Europe 2013 in the
context of PulseAudio and IIR filters. If access to the original samples
since the beginning of that period is not lost, then we can rewind to
the period boundary earlier than needed, then restore the state and
reapply the samples between that period boundary and the point we
actually wanted to reply to. So the net effect would be "can rewind to
anything except the currently playing period". OTOH I know another
approach that would make only a few samples non-rewindable (i.e. will
look similar to the 1.33ms limitation), and I will probably try to
implement it on my vacation as a new proof-of-concept library.
--
Alexander E. Patrakov
next prev parent reply other threads:[~2014-04-25 14:12 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 [this message]
2014-04-26 1:32 ` Raymond Yau
2014-04-26 10:01 ` Alexander E. Patrakov
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=535A6C96.7040109@gmail.com \
--to=patrakov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=david.henningsson@canonical.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).