tags:

views:

993

answers:

5

What is the best audio playback api for C/C++ for Linux, preferrably free/open source? I need it for embedded Linux, so I'm looking for something as lightweight as possible with not to many dependencies? Thanks a lot!

+1  A: 

SDL is really nice

singpolyma
however, SDL audio/mix API is really inefficient, and do not make use of mixing capability of audio backend.
elmarco
+2  A: 

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.

unwind
Thanks. I was looking primarily looking to playback .wav files
Rolle
playing back .wav is a job for libcanberra, which supersede esound in this domain and bring better functionality and extensibility.
elmarco
+2  A: 

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).

lothar
And pulse doesn't have to be big, IIRC. Its configure script (I think) allows large parts to be compiled out.
MighMoS
+1  A: 

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.

Zifre
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.
MSalters
+1  A: 

Depending on your use case, I would check out gstreamer or STK.

tmatth