Need more than 32 USB sound cards on my system [closed]
Asked Answered
T

2

7

I'm working on an educative multiseat project where we need to connect 36 keyboards and 36 USB sound cards to a single computer. We're running Ubuntu Linux 12.04 with the 3.6.3-030603-generic kernel.

So far we've managed to get the input from the 36 keyboards, and recognized the 36 sound cards without getting a kernel panic (which happened before updating the kernel). We know the 36 sound cards have been recognized because $ lsusb | grep "Audio" -c outputs 36.

However, $ aplay -l lists 32 playback devices in total (including the "internal" sound card). Also, $ alsamixer -c 32 says "invalid card index: 32" (works just from 0 through 31 ; 32 in total too).

So my question is, how can I access the other sound cards if they're not even listed with these commands? I'm writing an application in python and there are some libraries to choose from, but I'm afraid they'll also be limited to 32 devices in total because of this. Any guidance will be useful.

Thanks.

Turnover answered 7/1, 2013 at 18:8 Comment(4)
Are you afraid or have you tested it?Camilia
I tried pyaudio, and get_device_count() lists 32 in total, including some aliases (not sure if the right word) such as "default". So I can access even less devices.Turnover
How did you connect all these devices to the PC? Won't this be too much for the bus bandwidth? Can you actually use the current 31 devices all at the same time?Pentup
For the application we're trying out, they don't need to be all playing simultaneously (but all of them have to play sound at some point). They're connected using 2 root hubs connected to another level of hubs with 3 sound cards and 3 keyboards each. We've yet got to find out if it works this way or find another solution, such as adding another root hub and redistributing them, or adding a queue or something. I'll read about the bus bandwidth, thanks ;)Turnover
B
7

The question you pose is basically: Can there be more then 32 sound cards in the system controlled by ALSA? It obviously seems that while your USB controllers know all sound cards you attached, the ALSA system does not.

Let's get into the kernel sources to check what's going on here. In /sound/core/sound.c you will find more information about the issue of maximum sound cards:

  39 static int cards_limit = 1;
  40 
  41 MODULE_AUTHOR("Jaroslav Kysela <[email protected]>");
  42 MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
  43 MODULE_LICENSE("GPL");
  44 module_param(major, int, 0444);
  45 MODULE_PARM_DESC(major, "Major # for sound driver.");
  46 module_param(cards_limit, int, 0444);
  47 MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");
  48 MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
  49 
  50 /* this one holds the actual max. card number currently available.
  51  * as default, it's identical with cards_limit option.  when more
  52  * modules are loaded manually, this limit number increases, too.
  53  */
  54 int snd_ecards_limit;
  55 EXPORT_SYMBOL(snd_ecards_limit);

From the code and its comments I read two things:

  1. The variable cards_limit is a module parameter. I assume that on your installation this parameter is set to 32. If ALSA support is built into the kernel you can build a custom kernel where you changed this option. If ALSA support is not built-in, but loaded as a module, you can set this parameter during module load. For this you either change your system config (man modprobe.d) or unload the module, then reload it with the option (man modprobe).

  2. The limit is described to only limit the number of automatically loaded soundcards. To overcome this limit, it may suffice to manually load the module responsible for your soundcards. There is no limit set in the kernel for manually added soundcards.

Source: Kernel 2.8 Git

Bicapsular answered 7/1, 2013 at 18:41 Comment(1)
The auto-loading mechanism affected by cards_limit is not used for USB sound cards. Manually loading snd-usb-audio cannot change anything because it's the same driver for all 36 devices.Pentup
P
3

The sound card limit is defined as the symbol SNDRV_CARDS in include/sound/core.h.

When I increased this seven years ago, I did not go beyond 32 because the card index is used as a bit index for the variable snd_cards_lock in sound/core/init.c, and I did not want to change more than necessary.

If you make snd_cards_lock a 64-bit variable, change all accesses to use a 64-bit type, and adjust any other side effect that I might have forgotten about, you should be able to get the kernel to have more ALSA cards.

This limit also exists in the alsa-lib package; you will have to change at least the check in snd_ctl_hw_open in src/control/control_hw.c.

Pentup answered 7/1, 2013 at 20:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.