clinuxkernelalsalibasound

ALSA Kernel API is different from the asoundlib API?


I was reading about how to play audio from the linux kernel when I came across the ALSA (advanced linux sound architecture) and its api here in these kernel docs: https://www.kernel.org/doc/html/latest/sound/kernel-api/alsa-driver-api.html.

However it seems that most people who try to play audio in linux use the asound library, commonly included as so.

#include <alsa/asoundlib.h>

But when I look through the asoundlib api here: https://www.alsa-project.org/alsa-doc/alsa-lib/ it seems to not have the same functions as the kernel api I linked above. At this point I am confused because I am not sure when to call the kernel api vs the asoundlib api when playing audio.

A good example of this is the asoundlib api has a function called snd_pcm_open to create a handle and connection to an audio interface. I am unable to find this function in the kernel docs. So I am wondering, does asoundlib call the kernel api functions or are both of these apis orthogonal? If they are orthogonal, then what kerenel calls does asoundlib make?


Solution

  • ALSA project - the C library reference

    The section Preface states:

    The Advanced Linux Sound Architecture (ALSA) comes with a kernel API and a library API. ...

    The section API usage states:

    Application programmers should use the library API rather than the kernel API. The library offers 100% of the functionality of the kernel API, but adds major improvements in usability, making the application code simpler and better looking. In addition, future fixes or compatibility code may be placed in the library code instead of the kernel driver.