[alsa-devel] paravirtualized alsa kernel driver for XEN

Clemens Ladisch clemens at ladisch.de
Thu Mar 22 13:09:09 CET 2012

Stefano Panella wrote:
> The backend in dom0 is a userspace process using portaudio on top of alsa.
> The process is running in realtime priority and is calling a callback to
> feed data every 64 frames.
> In the callback I copy 64 frames from the shared pages to the portaudio
> buffer and update the HW pointer in an other shared page accordingly.

If PortAudio requires to use a callback, this is the only algorithm
that you can implement.

> Would it be possible to run the backend in dom0 kernel space and to use
> my shared pages from the alsa-driver in the VM as real pages for the HW?

No, the buffer pages are always under the control of and allocated by
the actual driver (some devices might have special requirements, or do
not support mmap at all).

If the actual driver support mmap, you would have to map these dom0
pages into the VM, and I guess this is not possible. (?)

As far as I can see, you have two options:

1) Stay with the current algorithm.  You get an additional latency
   corresponding to dom0's buffer size, and your process is forced to
   wake up every 64 frames (or whatever PortAudio is configured for).

2) Replace PortAudio with ALSA in the backend, and implement the copy
   callback in your driver.  Any call of snd_pcm_write*() in the VM will
   result in one or more calls to your driver's copy(), which should end
   up as a call to snd_pcm_write*() in dom0.  (Using the copy callback
   also implies that the driver does not support mmap.)


More information about the Alsa-devel mailing list