4
votes

I'm writing a cross-platform Qt-based program that from time to time needs to play back audio supplied externally (outside my control) as raw PCM. The exact format is 16 bit little-endian PCM at various common sample rates.

My first obvious idea was to use Qt's own Phonon for audio playback, but there are two problems with this approach:

  1. As far as I can see, Phonon does not support headerless PCM data. I would have to hack around this and fake a WAV header every time playback starts. Not a showstopper, though.
  2. More importantly: There doesn't seem to be any way to control how Phonon (and its backends such as xine, PulseAudio, DirectX, whatever) prebuffers. Its default behaviour seems to be something like 5 seconds of prebuffering, which is way too much for me. I'd prefer about 1 second, and I'd definitely like to be able to control this!

I'm currently looking at Gstreamer, FFMPEG and libvlc. Any thoughts? Since my audio is in a very simple format and I don't need to do fancy mixing stuff (just volume control), I'd like a simple, free (as in freedom), cross-platform and widely available library.

3

3 Answers

6
votes

Qt 4.6 has the new QtMultimedia module.

https://doc.qt.io/archives/4.6/qtmultimedia.html

The QAudioOutput class would seem to do what you want - it just plays raw PCM data.

3
votes

ffmpeg, libvlc and gstreamer have abilities beyond raw pcm, such as codec support.

For your purposes, SDL (example 1, example 2), OpenAL, QAudioOutput are sufficient. SDL is probably the most popular option.

Also, why do you want to control buffering? Buffering a lot means less interrupts and lower power consumption.

1
votes

Have you looked at OpenAL?