FFmpeg Audio Playback Sample

It was very hard to find a proper sample code that would compile with the newest FFmpeg library, and when some compiled they didn’t play correctly. This one however runs great, the planar audio channel playback was added by me, and later support for float playback(double PCM follows the same but wasn’t added due to media files being scarce) so now it plays the majority of MP3s, WMAs, AACs … and any audio format that you can name, I guess. I modified the code that was found here http://stackoverflow.com/questions/9799560/decode-audio-using-libavcodec-and-play-using-libao many thanks to him. This code was adapted from C, so somethings have not been thoroughly converted to C++; it compiles and runs anyway.


Please refer to this updated code

Compile with

g++ -std=c++11 test.cpp `pkg-config --libs --cflags libavcodec libavformat libavutil ao`

For MSVC, use this libao version: https://github.com/manushanga/libao-win32