Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: ov_open_callbacks Performance (Read 5292 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.

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,
Quote
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!