[opus] playback of opus files using portaudio
Timothy B. Terriberry
tterribe at xiph.org
Thu Dec 5 13:36:10 PST 2013
Akshit Jain wrote:
> I am making a lightweight opus audio player. This is my portaudio
> callback function. But i hear a stammering song when i try to play a
> .opus song file. Can anybody say what is wrong or provide me link to any
> code which can play opus file written in c/c++(light). I tried to see
> some open source(vlc opus play) but was unable to follow.
See opusfile_example.c in the examples/ directory of libopusfile.
./opusfile_example foo.opus | aplay
makes a rudimentary player.
You're using op_read(), but ignoring the link number. This will do the
wrong thing on chained files where the number of channels changes
between links. You can use op_read_stereo() to get a fixed number (2) of
channels out regardless of the number of channels in each link.
You're also not handling error return values. That should not be a
problem on properly encoded files, but it is a potential security
vulnerability, since you're using the return value to do pointer arithmetic.
What do your Pa_OpenStream() parameters look like?
More information about the opus