4

I'm having a hard time figuring out how to make a Linux PCM playback device which entirely works in user space. When the application calls snd_pcm_open/snd_pcm_readi/writei, I want does calls to end up in a user space driver and the pcm data to be handled in a thread created when the user space driver was initialized. The audio process thread will then call an actual ALSA kernel driver which will output pcm to HW. This is basically what I want to achive:

Application -> ALSA (pcmC1D0p) -> Audio process thread (user space) -> ALSA (pcmC0D0p) -> HW

I have looked a little bit at plugins but not sure it that is the correct way to do it? Also not sure how to actually start my plugin? I have compiled a .so file not not sure where to place it or how/what calls it?

Any pointers would be greatly appreciated.

niom
  • 41
  • 3

1 Answers1

0

Something like this can be done with the external filter plugin SDK, which is basically undocumented.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • Yes so that's i basically what I have done. I'm able to compile my plugin which calls snd_pcm_ioplug_create(). What I don't understand is where should I place the .so file? There was a reference to place it in usr/lib/alsa-lib, as I didn't have a folder called alsa-lib I created one and placed my .so file there but then what? How does that make a new device appear in /dev/snd so an application can use it? – niom Feb 01 '16 at 12:41
  • `/dev/snd/` contains kernel devices. And ioplug is not extplug. – CL. Feb 01 '16 at 12:57
  • I chose ioplug because it sounded more like what I was after, a user space driver: "The I/O-type plugin is a PCM plugin to work as the input or output terminal point, i.e. as a user-space PCM driver." So if the will not show up in /dev/snd/, how is an application suppose to use it? When an application calls snd_pcm_open(), how does it end up in my plugin? http://www.alsa-project.org/alsa-doc/alsa-lib/pcm_external_plugins.html – niom Feb 01 '16 at 14:15
  • See some existing plugin using extplug, e.g., speexdsp/upmix/vdownmix in the alsa-plugins package. – CL. Feb 01 '16 at 20:07
  • I had a look at it and I think I'm on the right path. But for some reason I don't understand ALSA can't open my shared library? I have placed it in the alsa-lib folder where libasound_module_pcm_speex.so is also located, but after i have changed in .asoundrc to use my plugin and run aplay, ALSA complains? "ALSA lib dlmisc.c:252:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_myplug.so" – niom Feb 03 '16 at 08:50
  • .asoundrc: pcm.primary { type myplug } – niom Feb 03 '16 at 08:50
  • Yes: $ ldd /usr/lib/x86_64-linux-gnu/alsa-lib/libasound_module_pcm_myplug.so – niom Feb 03 '16 at 09:28
  • linux-vdso.so.1 => (0x00007ffdfbfc9000) – niom Feb 03 '16 at 09:28
  • libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f376c341000) – niom Feb 03 '16 at 09:28
  • /lib64/ld-linux-x86-64.so.2 (0x000055d2f3671000) – niom Feb 03 '16 at 09:28