[pulseaudio-discuss] [PATCH] module-virtual-sink: Speed up draining

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Sun Oct 19 03:57:18 PDT 2014


On Thu, 2014-10-02 at 15:58 +0200, David Henningsson wrote:
> The drain speed increase done a while ago, only worked when directly connected
> to ALSA sinks. Playing through an module-virtual-sink would cause slower drains.

What about other virtual sinks? Shouldn't the same fix be applied to
those too?

> This fix has two parts:
>  1) We now refuse to process handed out silence. This has the effect
>     that it tells ALSAs sink input that we're draining, and that we want to

s/ALSAs sink input/the ALSA sink/ ?

>     be woken up exactly at this sample based point in time.
>  2) When we're being called to process input underruns, we know this has
>     happened, so we can just forward the call up the sink chain to get
>     to protocol-native, which can acknowledge that the drain has completed.
> 
> This fix is incomplete, because if more than one sink input is playing back
> into the sink, only the last one will be drained in time. But it's better
> than nothing.

A comment about this shortcoming in the code would be good.

> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
> 
> Happy for testing of this patch - Ubuntu runs HDA-intel with 64K buffers instead of the 2M that
> some distros use, so I'm not seeing that much difference that you do anyway.

The buffer size can be changed at runtime:
echo 2048 > /proc/asound/card0/pcm0p/sub0/prealloc

> Also, when I was testing, I also noticed a bigger startup latency when playing
> back through a virtual sink. This is nothing I have looked deeper at.
> 
>  src/modules/module-virtual-sink.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/src/modules/module-virtual-sink.c b/src/modules/module-virtual-sink.c
> index 66fd8a9..c1e5969 100644
> --- a/src/modules/module-virtual-sink.c
> +++ b/src/modules/module-virtual-sink.c
> @@ -216,6 +216,10 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
>          pa_memchunk nchunk;
>  
>          pa_sink_render(u->sink, nbytes, &nchunk);
> +        if (nchunk.memblock == u->sink->silence.memblock) {
> +            pa_memblock_unref(nchunk.memblock);
> +            return -1;
> +        }

I think this needs a comment explaining what it implies if
pa_sink_render() returns silence and why it makes sense to return -1 in
that case.

-- 
Tanu



More information about the pulseaudio-discuss mailing list