<Sound Dev> Support for linux alsa PCM devices

Pavel Hofman pavhofman at gmail.com
Sun Jun 16 08:46:16 UTC 2019


Linux alsa sound subsystem allows defining custom PCM devices, apart
of the card-based devices (hw:CARD:UI.DEVICE_ID). These devices are
very flexible and allow lots of useful and important features. An
example where java support for PCM devices is very needed is

Java enumerates the main "default" device
and then only devices corresponding to hardware cards
. The JDK code does mapping between java deviceID and alsa string
device name.

There is a hard-coded constant ALSA_DEFAULT_DEVICE_ID which
corresponds to string "default" for snd_pcm_open. Alsa devices
corresponding to cards use IDs starting from 1

It would be possible to start the encoded card IDs e.g. from 11 and
keep the 10 lower IDs reserved for the alsa PCM devices, just like the
first value (0) is reserved for the fixed string "default". PCM
devices to enumerate could be specified by an environment variable as
a comma separated list of strings. E.g. wine does it this way using a
register entry https://wiki.winehq.org/Sound#ALSA . The number of
devices enumerated would be limited to 10, all other items in the
variable would be ignored.

The alsa java sound module is already partly configured via
environment variables  -

The module would hold static array of strings with names of the
additional PCM devices, initialized in the method iteratePCMDevices()
. The array would map the PCM device strings:  pcm_devices[deviceID
-1] if deviceID were between 1 and 10.

This addition would greatly enhance capabilities of java sound apps on linux.

If you agree with the proposal, I can start working on a patch.

Best regards,

Pavel Hofman.

More information about the sound-dev mailing list