[alsa-devel] Polling issues with the PCM multi plugin

Takashi Iwai tiwai at suse.de
Thu Dec 13 07:34:15 CET 2012


At Wed, 12 Dec 2012 21:57:56 -0800,
Devin Anderson wrote:
> 
> Hi all,
> 
> On the jack-devel list, we've been having a discussion about the ALSA
> PCM multi plugin:
> 
>     http://thread.gmane.org/gmane.comp.audio.jackit/26571/focus=26571
> 
> I've been having some issues with setting up my 2 Echo Layla 3Gs as a
> PCM multi.  In particular, I've found that there are times when
> polling the file descriptors of the multi when poll() returns, but
> there isn't actually a period of data available for capture/playback,
> even though the poll descriptors indicate that the data should be
> available.  After some debugging and learning about the PCM multi
> driver:
> 
> 1.) The PCM multi driver only returns poll descriptors for one of the
> devices that makes up the multi
> 2.) When this happens, the device that's actually being polled *does*
> have data available
> 3.) When this happens, the device that's not being polled does not yet
> have a period's worth of data available
> 
> After making sure that I had word clock enabled and that my word clock
> cable was working properly, I started delving into the problem some
> more.  From what I can gather, the PCM multi device uses the function
> `snd_pcm_link()` to sync its devices, and, for start, stop, drain,
> pause, suspend, resume, reset, and prepare operations, this appears to
> work fine; however, I can't find any evidence that a PCM device checks
> to make sure that all of its linked slave devices have their poll
> descriptors ready with events before indicating that events are
> available.
> 
> Questions:
> 
> 1.) Should `snd_pcm_link` make I/O availability indication dependent
> on I/O availability of its linked slave devices?

The PCM stream link has nothing to do with the poll descriptors.
It's basically only for performing the synchronized trigger.

> 2.) If not, how should this operation be handled?  I'm sure it *can*
> be handled in userspace by bypassing the multi and polling the file
> descriptors of all sound cards directly, but duplicating this code for
> each application that wants to poll multiple sound cards seems wrong.

Actually there were multiple poll descriptors for multi plugin in the
early version of alsa-lib.  But this was changed to a single fd by
some reason I don't remember.  I thought there were too many broken
apps doing wrong for multiple fds.

Maybe as a compromised solution, we'd need to introduce a config
option to multi plugin for allowing multiple fds.


Takashi


More information about the Alsa-devel mailing list