Skip to main content

Topic: Going back to beginning in non-seekable streams? (Read 3510 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
Going back to beginning in non-seekable streams?
What's the fastest way to go back to the beginning of a non-seekable Ogg/Vorbis stream?

I'd prefer not to have to reopen it because that can easily take 50ms on the slow mobile platform that starts with "i" that I'm working on. It can easily take a second to open an Ogg/Vorbis file as seekable, so we're opening all of our files as non-seekable. But we still need to loop them, and some of them are music files - a bit too big to decompress into memory.

  • m00
  • [*]
Going back to beginning in non-seekable streams?
Reply #1
What's the fastest way to go back to the beginning of a non-seekable Ogg/Vorbis stream?

I'd prefer not to have to reopen it because that can easily take 50ms on the slow mobile platform that starts with "i" that I'm working on. It can easily take a second to open an Ogg/Vorbis file as seekable, so we're opening all of our files as non-seekable. But we still need to loop them, and some of them are music files - a bit too big to decompress into memory.


Can't you just cache the first few KBs of the stream when you first open it ? Then use that to decode from whilst the file is being re-opened in the background or something ? If you only need to cover 50ms or so then you'll need a tiny amount of memory to cache the start.. Even with a stream at 128Kb/s that's still only 16KB a second so 4K would cover you for easily a quarter of a second.. I don't know how much gumpf sits at the start of Ogg streams, but I can't imagine it's too much..

Going back to beginning in non-seekable streams?
Reply #2
The problem isn't the I/O. I'm using ov_open_callbacks and memory-mapped files. We have measured our I/O performance and found it to be very efficient - much faster than seeking.

Our product is an audio SDK for video games. We don't have the option of tying up the CPU for that long.

So there's no efficient way to jump back to the beginning of an Ogg/Vorbis file? Or at least, nothing faster than closing it and reopening it?