title: Multiple USB audio cards under linux
body: <p>We have a service which uses a PC with multiple audio capture cards attached:</p>
  
  <pre><code>&gt;cat /proc/asound/cards 
  1 [Device         ]: USB-Audio - USB PnP Audio Device
                      C-Media Electronics Inc. USB PnP Audio Device at usb-0000:00:1a.0-1.5.1, full s
  2 [Device_1       ]: USB-Audio - USB PnP Audio Device
                    C-Media Electronics Inc. USB PnP Audio Device at usb-0000:00:1a.0-1.5.2, full s
  3 [Device_2       ]: USB-Audio - USB PnP Audio Device
                    C-Media Electronics Inc. USB PnP Audio Device at usb-0000:00:1a.0-1.5.3, full s
  </code></pre>
  
  <p>The machine spec we are using should allow for 32 mono or 16 stereo channels.
  This seems to work for some applications but not others.</p>
  
  <p>In particular for one service we see errors in the kernel log /var/log/kern.log if we try to use more than a certain number of channels at once:</p>
  
  <pre><code>May 20 11:51:43 pc706348 kernel: [70614.334363] usb 1-1.5.5.4: cannot submit urb 0, error -28: not enough bandwidth
  May 20 11:51:44 pc706348 kernel: [70614.485628] usb 1-1.5.5.4: cannot submit urb 0, error -28: not enough bandwidth
  May 20 11:51:44 pc706348 kernel: [70614.609568] usb 1-1.5.5.4: cannot submit urb 0, error -28: not enough bandwidth
  </code></pre>
  
  <p>This is using Debian 9.12 with Kernel 4.9.0-12-amd64.</p>
  
  <p><strong>Q What could be the cause and what might we do about it?</strong></p>
  
  <p>We have a file in /etc/modprobe.d/audiobox.conf to configure the soundcore module which is common to both the working and non-working scenarios:</p>
  
  <pre><code>options snd-usb-audio index=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 vid=0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c,0x0d8c pid=0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132,0x0132
  </code></pre>
  
  <p>Both working and non-working applications access the sound cards using the snd_pcm_ family of API calls
  and seem to be executing the same sequence with the same parameters.
  At this level we get overflow errors being reported rather than "cannot submit urb" which is at a lower-level.</p>
  
  <p>Caveat: I have not seen both working and non-working applications on the same machine myself but the hardware specification is the same. 
  I have not been able to enumerate any obviously significant differences through remote shell sessions.</p>
  
  <p>I am also able to reproduce the error using the <code>rec</code> utility from the <code>sox</code> package.</p>
  
  <p>Any there any issues that might be reported as "not enough bandwidth" when it is actually some other kind of error?</p>
  
  <p>Is there some way to alter/limit the USB bandwidth consumed by an ALSA device, either programmatically or via the alsa.conf?</p>
  
  <p>There are some relevant questions about this which do not help:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/43615831/linux-limit-usb-device-bandwidth">Linux - Limit USB Device Bandwidth</a></li>
  <li><a href="https://superuser.com/questions/423150/how-can-i-limit-the-amount-of-usb-bandwidth-consumed-by-a-single-usb-port-device">https://superuser.com/questions/423150/how-can-i-limit-the-amount-of-usb-bandwidth-consumed-by-a-single-usb-port-device</a></li>
  </ul>