Skip to main content

Topic: ov_open_callbacks Performance (Read 4078 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
ov_open_callbacks Performance
We're having some performance problems ov_open_callbacks in our audio system designed for video games. The system is aimed at downloadable games, so we were hoping that we could store all of our sounds in ogg vorbis format.

The files are all concatenated into one big resource file, which is why we use ov_open_callbacks.

The performance problems seem to come from the fact that the ov_open_callbacks keeps seeking and reading a byte at a time. I have made various optimizations in order to avoid seeking more than is necessary. But the performance is still very slow. It can easily take 50 ms to open an ogg file on a current Windows machine. As a result, we open all of our ogg files at init time. This solves the audio glitches, but is obviously not ideal, by any stretch.

On an Intel-based mobile platform (which I can't name because of NDA) the results are simply disasterous. It takes over a second to open a stereo ogg/vorbis file!!!

Part of the problem is that ov_open_callbacks does a lot off seeking and reading a byte at a time. I have tried to optimize my callback functions by seeking only when necessary.  But I still don't understand why it can take a second to open a file.

Is there anything I can do in order to speed it up?

I tried to look at the way I was encoding the files, but the only thing I could come up with was to take out the comments. No difference. Would using a fixed bit-rate or lower compression ratio help things?

Thanks in advance for any help here.

  • Yirkha
  • [*][*][*][*][*]
  • FB2K Moderator
ov_open_callbacks Performance
Reply #1
Ogg Vorbis streams can also be read in one-pass for use in streaming, for example. If you don't need to seek to arbitrary offsets in one Vorbis file, you might try disabling seeking completely. As libvorbisfile says,
If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided seek callback should always return -1 (failure) or the seek_func and tell_func fields should be set to NULL.
Full-quoting makes you scroll past the same junk over and over.

ov_open_callbacks Performance
Reply #2
What a difference!

Thanks very much for this!