Minimising alsa-lib

As I said before, I’ve been working on trying to improve the ALSA packages in Gentoo, so you can see in 1.0.14 series that the ALSA_CARDS values are shown by portage so that you know which one you can enable, and at least for some of them you get a failure if you try to enable them without the correct configuration options in the kernel.

Today, I wanted to try minimising the footprint of alsa-lib, as that is a library that almost every system has loaded in a few instances.. the trick I had in mind (and I have locally realised) is to allow users to choose the PCM plugins they want to compile in the library… the PCM plugins are things like dmix and dsnoop (used for software mixing of, respectively, output and input), iec958 (passthrough digital audio) and plug (resampling), but they are not the only ones of course. They are the bricks that compose the asound.conf files.

Of course a normal system rarely uses all of the plugins that are usually built in alsa-lib, and for some particular setups (mine included), the used plugins are very very limited. That’s why attacking the amount of plugins built was my first choice, so I created an ALSA_PCM_PLUGINS variable and used that to decide what had to be built and what not; in my case just plug and iec958, as I use PulseAudio for software mixing (I also have some space for hardware mixing if I need to bypass PulseAudio) and plug is pretty much a Swiss knife.

Also, there’s the ALISP interpreter used for very complex setups, and there is the whole support for MIDI stuff (instruments, sequencers, sample loaders, rawmidi output) that is unlikely to be used on most of modern systems (MIDI has a pretty much limited use nowadays, considering the kind of sound cards we have available; even software like Audacious that play .mid files is simply using software synthesis rather than hardware instruments).

My pretty much limited setup shows now this:

[ebuild   R   ] media-libs/alsa-lib-1.0.14_rc1  USE="-alisp -debug -doc -midi"
ALSA_PCM_PLUGINS="-adpcm -alaw -asym -copy -dmix -dshare -dsnoop -empty
-extplug -file -hooks iec958 -ioplug -ladspa -lfloat -linear -meter -mulaw -multi
-null plug -rate -route -share -shm -softvol" 0 kB

and the size of the package (built with -ggdb) is down from 6.4MB to 3.4MB now, that’s almost half of the previous size. Considering that a big part of that package is composed of configuration files, the size of the library decreased sensibly.

I’m waiting to hear comments on gentoo-dev before proceeding with adding the variable, the defaults and the ebuild itself, but if all goes as I hope, alsa-lib from Gentoo would be also simpler to use on embedded devices.

Exit mobile version