Linux – How to use synchronous endpoint of USB audio device


I want to play the same sound over several USB audio devices in sync. Last time I tried something like this was about 2001 and it was successful — and the pair of Griffin iMics I used back then still work in that usage, but I want more channels now.

I'm having trouble getting this to work with more recent USB Audio devices. I have some devices with C-Media chips, which creates a lot of crackles and pops and drift out of sync relative to the iMics; another device with a TI chip doesn't crackle but still drifts out of sync.

According to my understanding of how USB audio works, the sync problems would be consistent with the iMics using Synchronous clocking and the others using Asynchronous clock.

Now, when I do lsusb -v I see that each of my devices exposes multiple endpoints, some Synchronous, some Asynchronous, and some Adaptive. So I need some way to instruct the audio driver to use the synchronous endpoint.
That's where I'm stuck.

  • How can I tell which endpoints are being used? lsof reports a /dev/snd/pcmXXXXX are in use, but I'm not sure whether that corresponds to any particular endpoint. I can see information about endpoints in /sys/bus/usb but I don't know how to tell of any of the endpoints are active.
  • How can I change which endpoint is used, by configuring ALSA or some other library? I've tried looking through the ALSA sources but haven't found any parts that tell how it selects which endpoint to use.

Best Answer

The USB specification defines three synchronization modes for isochronous endpoints: synchronous, asynchronous, and adaptive.

Nobody uses synchronous. For playback endpoints, adapative means that the device runs at exactly the speed at which the PC decides to sends data; asynchronous means that the device tells the PC how fast it should send data (this is done through a second endpoint in the other direction).

An asynchronous device typically has three isochronous endpoints: one asynchronous output endpoint for playback samples, one input endpoint for playback frequency feedback data, and one asynchronous input endpoint for capture samples. It might also have interrupt and bulk endpoints for mixer control, MIDI, and vendor-specific stuff.

The USB audio driver prefers an adaptive endpoint over an asynchronous endpoint, if possible. (But I don't know of any current device that actually has different endpoint types for the same output; the C-Media CM66xx chips certainly don't.)

So if you want to run multiple devices at the same speed, you cannot affect anything with software configuration; you must use devices that you know support adaptive mode.