What is the best audio playback api for C/C++ for Linux, preferably free/open source? I need it for embedded Linux, so I'm looking for something as lightweight as possible with not to many dependencies?
5 Answers
That depends on what you mean by "audio". If you just want to play back raw PCM sample data, look at using the ALSA API directly. If you want to decode and play back encoded sound, you need to look at libraries supporting the required format(s), of course.
-
-
playing back .wav is a job for libcanberra, which supersede esound in this domain and bring better functionality and extensibility.– elmarcoJul 8, 2009 at 12:10
PulseAudio has been adopted by the major distributions and it looks like it is the upcoming Linux Audio standard as it is more flexible than ALSA. Here's an article about why you should care about PulseAudio (and how to start doing it).
-
And pulse doesn't have to be big, IIRC. Its configure script (I think) allows large parts to be compiled out.– MighMoSApr 21, 2009 at 17:20
SDL is really nice
-
however, SDL audio/mix API is really inefficient, and do not make use of mixing capability of audio backend.– elmarcoJul 8, 2009 at 12:01
If you are doing embeded stuff, I would use ALSA directly (although it is quite complex). I definitely wouldn't use something like PulseAudio, because it is quite heavy and adds just another layer (a whole separate server). SDL might be okay, but it is mainly meant for games.
-
Not sure how this got a downvote. Embedded Linux can be quite small. Throwin stuff like PulseAudio on systems that don't need it will just increase the amount of RAM needed and thus the BOM costs.– MSaltersApr 22, 2009 at 11:07