Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1705623

Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period interrupt emulation

From Oleksandr Andrushchenko <andr2000@gmail.com>
Newsgroups linux.kernel
Subject Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period interrupt emulation
Date 2017-08-07 17:20 +0200
Message-ID <ubRYZ-1OG-7@gated-at.bofh.it> (permalink)
References (2 earlier) <ubNC2-714-13@gated-at.bofh.it> <ubOy6-7Bo-21@gated-at.bofh.it> <ubQ6S-fz-21@gated-at.bofh.it> <ubQqd-nB-7@gated-at.bofh.it> <ubQJz-xP-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 08/07/2017 04:55 PM, Clemens Ladisch wrote:
> Oleksandr Andrushchenko wrote:
>> On 08/07/2017 04:11 PM, Clemens Ladisch wrote:
>>> How does that interface work?
>> For the buffer received in .copy_user/.copy_kernel we send
>> a request to the backend and get response back (async) when it has copied
>> the bytes into HW/mixer/etc, so the buffer at frontend side can be reused.
> So if the frontend sends too many (too large) requests, does the
> backend wait until there is enough free space in the buffer before
> it does the actual copying and then acks?
Well, the frontend should be backend agnostic,
In our implementation backend is a user-space application which sits
either on top of ALSA driver or PulseAudio: so, it acks correspondingly,
e.g, when, for example, ALSA driver completes .copy_user and returns
from the kernel
> If yes, then these acks can be used as interrupts.
we can probably teach our backend to track periods elapsed for ALSA,
but not sure if it is possible for PulseAudio - do you know if this is also
doable for pulse?

Let's assume backend blocks until the buffer played/consumed...
>    (You still
> have to count frames, and call snd_pcm_period_elapsed() exactly
> when a period boundary was reached or crossed.)
... and what if the buffer has multiple periods? So, that the backend sends
a single response for multiple periods (buffers with fractional period 
number
can be handled separately)?
We will have to either send snd_pcm_period_elapsed once (wrong, because
multiple periods consumed) or multiple times at one time with no delay 
(wrong,
because there will be a confusion that multiple periods were not 
reported for quite
some long time and then there is a burst of events)
Either way the behavior will not be the one desired (please correct me
if I am wrong here)
>
> Splitting a large read/write into smaller requests to the backend
> would improve the granularity of the known stream position.
>
> The overall latency would be the sum of the sizes of the frontend
> and backend buffers.
>
>
> Why is the protocol designed this way?
We also work on para-virtualizing display device and there we tried to use
page flip events from backend to frontend to signal similar to
period interrupt for audio. When multiple displays (read multiple audio 
streams)
were in place we flooded with the system interrupts (which are period 
events in our case)
and performance dropped significantly. This is why we switched to
interrupt emulation, here via timer for audio. The main measures were:
1. Number of events between front and back
2. Latency
With timer approach we reduce 1) to the minimum which is a must (no period
interrupts), but 2) is still here
With emulated period interrupts (protocol events) we have issue with 1)
and still 2) remains.

So, to me, neither approach solves the problem for 100%, so we decided
to stick to timers. Hope, this gives more background on why we did things
the way we did.
>   Wasn't the goal to expose
> some 'real' sound card?
>
yes, but it can be implemented in different ways, please see above
> Regards,
> Clemens
Thank you for your interest,
Oleksandr

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/11] ALSA: vsnd: Add Xen para-virtualized frontend driver Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 01/11] ALSA: vsnd: Implement driver's probe/remove Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 06/11] ALSA: vsnd: Introduce ALSA virtual sound driver Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 10/11] ALSA: vsnd: Implement communication with backend Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 05/11] ALSA: vsnd: Implement handling of shared buffers Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 09/11] ALSA: vsnd: Implement ALSA PCM operations Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 02/11] ALSA: vsnd: Implement Xen bus state handling Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 07/11] ALSA: vsnd: Initialize virtul sound card Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
  [PATCH 08/11] ALSA: vsnd: Add timer for period interrupt emulation Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 09:50 +0200
    Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Clemens Ladisch <clemens@ladisch.de> - 2017-08-07 12:40 +0200
      Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 13:40 +0200
        Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Clemens Ladisch <clemens@ladisch.de> - 2017-08-07 15:20 +0200
          Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 15:40 +0200
            Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Clemens Ladisch <clemens@ladisch.de> - 2017-08-07 16:00 +0200
              Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 17:20 +0200
                Re: [alsa-devel] [PATCH 08/11] ALSA: vsnd: Add timer for period  interrupt emulation Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-08 08:10 +0200
  Re: [PATCH 00/11] ALSA: vsnd: Add Xen para-virtualized frontend  driver Takashi Sakamoto <o-takashi@sakamocchi.jp> - 2017-08-07 13:40 +0200
    Re: [PATCH 00/11] ALSA: vsnd: Add Xen para-virtualized frontend  driver Oleksandr Andrushchenko <andr2000@gmail.com> - 2017-08-07 13:40 +0200

csiph-web