[Vorbis] ov_raw_tell() not working properly!

Michael Smith mlrsmith at gmail.com
Wed Aug 17 01:34:33 PDT 2005


On 8/16/05, Diaa Sami <diaasami at yahoo.com> wrote:
> I'm working on an application where I need to record
> the current playing position and return to it later.
> and I need this to be done the most efficient way, so
> I used ov_raw_tell() and ov_raw_seek() because the
> documentation says they are the best when speed is a
> concern.
> but the problem is that sometimes ov_raw_tell returns
> the same value before and after calling ov_read;
> here's an example:
> 
> prevPos = ov_raw_tell(&vf);
> const long ret = ov_read(&vf, temp_buffer, 4096, 0,
> bytesPerSample, 1, &current_section);
> currentPos = ov_raw_tell(&vf);

Internally, libogg and libvorbis (used by vorbisfile) do some
buffering. So a read can sometimes be satisfied entirely from those
buffers - and in that case, the vorbisfile stream cursor doesn't need
to move. It only gets updated when vorbisfile actually needs to read
fresh data from the underlying data source (file or otherwise).

As the comment on ov_raw_tell() says: " Note that seek followed by
tell will likely not give the set offset due to caching" - if you need
accurate seeking, you can't use the raw functions.

How serious a concern is performance? The time-based seeking functions
(or the pcm offset ones) are accurate and generally not _that_ slow.

Mike


More information about the Vorbis mailing list