tags:

views:

44

answers:

2

What is the most portable way to play a wave file in Linux? I'd like this to succeed even if the user doesn't have particularly nice sound libraries installed (assume libc is installed and the user has sound configured, but nothing else).

Preferably, the method I use to blocks until the sound finishes playing and also avoids the overhead of launching a whole separate utility.

A: 

cat mywav.wav > /dev/dsp

so i guess write to that file with a wav file ?

see here

Paul Whelan
+2  A: 

The problem is, there's not really a Linux sound API. There's ALSA and OSSv4 for hardware access, but if you use either API directly, you will likely be fighting a mixing daemon, such as PulseAudio, for access to the sound device.

You may be best off using something like libao or PortAudio.

LnxPrgr3
Ended up doing an external call to aplay since ALSA was most available. Thanks.
mbac32768