[LAU] Dual Delta Setup

Devin Anderson surfacepatterns at gmail.com
Mon Dec 31 02:39:57 UTC 2012


On Sun, Dec 30, 2012 at 6:03 PM, Paul Davis <paul at linuxaudiosystems.com> wrote:

> the problem as it been described here, seems more to be:
>
>>
>> >
>> > So, you get a situation where poll() returns because there's data on
>> > the master device, but then the 'multi' device indicates there's no
>> > data because it checks all of the devices and returns the minimum
>> > value for the amount of data available, which JACK thinks is an xrun
>> > because the ALSA driver's wait function returns 0 when anything less
>> > than a period's worth of data is available, and a 0 result is
>> > interpreted as an xrun.  This results in tons and tons of xruns, as
>> > JACK essentially busy waits until there is actually a period of data
>> > available on all of the devices that make up the multi device.
>
> so they can be off by 1 sample (for example) and this can happen. ALSA needs
> to wait for the slowest/last of the linked devices, not the first. or so it
> appears.

Right.

Doing this in the multi device at the *userspace* level, AFAICT, is
either very hard or not possible due to the way poll descriptors are
handled within ALSA.  With the multi's implementation of
snd_pcm_poll_descriptors(), there are basically three choices:

1.) Return the master device's poll descriptors (the current implementation).

We know this doesn't work.

2.) Return the poll descriptors of all of the devices (the old
implementation, IIUC).

This would lead to the same issue, and possibly make it worse if the
slave devices are sometimes ready before the master device.

3.) Return a custom file descriptor (eventfd, maybe).  Do the device
polling in separate thread, and signal the file descriptor when enough
data is available on both devices.

I'm not even sure this is really doable in a way that could reliably
play well with all the applications that depend on this functionality.

I can't see any other way to do this at the userspace level.

At the kernel level, this problem might be able to be fixed by having
snd_pcm_link() sync the file descriptors of the master and slave
devices.  I have absolutely no idea what the ramifications would be.

-- 
Devin Anderson
surfacepatterns (at) gmail (dot) com

blog - http://surfacepatterns.blogspot.com/
midisnoop - http://midisnoop.googlecode.com/
psinsights - http://psinsights.googlecode.com/
synthclone - http://synthclone.googlecode.com/


More information about the Linux-audio-user mailing list