From: "Alexander E. Patrakov" <patrakov@gmail.com>
To: Raymond Yau <superquad.vortex2@gmail.com>
Cc: sergemp@mail.ru,
ALSA Development Mailing List <alsa-devel@alsa-project.org>,
Clemens Ladisch <clemens@ladisch.de>,
david.henningsson@canonical.com
Subject: Re: On non-rewindability of resamplers
Date: Wed, 28 May 2014 21:38:57 +0600 [thread overview]
Message-ID: <53860311.3000007@gmail.com> (raw)
In-Reply-To: <CAN8cciZaSZ0C7VoN=jtw_BN5zc=K_4yhqd0N8yuT74qz0kjKEQ@mail.gmail.com>
28.05.2014 13:58, Raymond Yau wrote:
> >>
>
> > Yes. The test program is attached. For stereo S16_LE output, it
> reports 32 samples (i.e. 128 bytes) as the minimum period size.
>
> your program segfault when using NULL plugin
Bug in the null plugin. snd_pcm_null_fast_ops lacks the .rewindable
field initialization, thus this callback gets defaulted to NULL. Thanks
for reporting.
>
> >
>
> >> what other events pulseaudio need to rewind beside
> >>
> >> 1) change in volume of sink/source
>
> Volume change of the sink is supposed to be real time event
>
> User are allowed to change the volume slider even when the sink is not
> playing or source is not capturing
>
> If the requested volume cannot be satisfied by changing hardware volume
> controls , does pulseaudio keep the calculated software volume
> adjustment when the sink start playing while the hardware volume is
> supposed to be updated immediately ?
The answer depends on the volume mode.
In the flat-volume mode, there is in fact no independent sink volume. If
at least one stream is playing, then the volume of the loudest stream is
applied as a sink volume, and other streams are attenuated accordingly.
So the answer to your question is "no", because starting the stream
changes the total volume of the sink, including the hardware part.
In the non-flat volume mode, the answer is "yes".
>
> when user specify ignore_DB=1 or codec does not have any volume control
> (e.g. SPDIF stereo playback) which force pulseaudio to use software volume.
>
> The software volume will be same as the requested volume(volume slider
> in sound preference) even when there is no playing stream.
>
> Do this software volume setting saved in pulseaudio database when
> shutdown and restore on pulseaudio next startup by
> module-device-restore for the SPDIF stereo profile ?
The volume is saved and restored as a whole. module-device-restore does
not care what part of the volume is software and what part is hardware.
>
>
> >> 2) change in volume of streams
>
> since there may be multiple streams (clients) playing at the same time,
> Do pulseaudio still keep copies of unmixed audio of all connected clients ?
Yes. Each sink input keeps some past audio in a memblockq, just in case
if the sink re-asks it.
>
>
> >> 3) change in latency
> >> 4) sync slaves of combined sinks
> >
> >
> > I don't think that (4) is valid. It is handled by resampling, not
> rewinding.
> >
> > 5) explicit rewrite request from the client (if the sink has already
> rendered the rewritten data into its buffer)
>
> > 6) state change ("If we are added for the first time...") of the sink
> input
>
> If the stream is the first client ,
>
> How about a low latency client connect to server when a high latency
> client is already playing ?
>
> Do pulseaudio still rewind the sink when low latency client is playing
> and a high latency client connect to server ?
Every new connection (and by "added for the first time" the comment
means exactly this) causes a full rewind.
>
> > 7) corking/uncorking
>
> Do you mean pause of the playing stream while other stream is still
> playing ?
Yes. The other case is when a music stream is paused automatically while
another stream (e.g. VoIP) is about to be played.
>
> > 8) end of underrun (for specific sink inputs)
>
> if appl_ptr is behind hw_ptr , you need to use snd_pcm_forward to
> advance the appl_ptr to a suitable position which you write enough data
> so that final appl_ptr is at least one period ahead of hwptr
>
> Why do end of underrun need rewind ?
Because we mean different kinds of underrun. You mean ALSA-level
underrun. The comment means PulseAudio-level underrun - i.e. one of the
streams failed to supply data in time, while the ALSA card got data
without the contribution from that stream.
So PulseAudio mixed a lot of data ahead without that stream, filled in
the ALSA buffer, and new data for that stream shows up. Obviously, it
needs to be heard right away, and thus already-mixed data should be
discarded by an ALSA-level rewind.
>
> > 9) moving streams between sinks
>
> What happen when the sinks have different buffer size ?
>
> Do all playing streams need to re-adjust latency ?
>
In theory, yes. The total latency is the sum of the latency of the sink
and the latency specific to the sink input. This sum needs to be
redistributed amongst these two parts.
However, the big comment after "case PA_SINK_MESSAGE_START_MOVE:" in
src/pulsecore/sink.c contains some FIXMEs about known bugs in this process.
--
Alexander E. Patrakov
prev parent reply other threads:[~2014-05-28 15:39 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
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 [this message]
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=53860311.3000007@gmail.com \
--to=patrakov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=david.henningsson@canonical.com \
--cc=sergemp@mail.ru \
--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).