[Vorbis] Trouble implementing ov_callbacks, endless loop calling seek_func

Rich E reakinator at gmail.com
Mon Feb 3 00:43:26 PST 2014


Well it looks like I got it working a day later... looks like I had
implemented SEEK_END wrong, although I'm not sure why this would lead to
the seek_func callback being called infintely.

Apologies for the noise, and thanks for the awesome and free sound file
format.

cheers,
Rich


On Sun, Feb 2, 2014 at 4:54 AM, Rich E <reakinator at gmail.com> wrote:

> Hello list,
>
> I've been having a tough time adding windows resource support to my ogg
> vorbise decoder, although I think I am close. Basically when I call
> ov_open_callbacks(), it doesn't ever return and repeatedly calls my
> seek_func.
>
> I'm hoping it is something obvious, but I can't see why my seek_func is
> being called endlessly.  If the file is seekable, I should return 0, right?
> If any one can take a look at the following callback functions and see if
> they can spot what I'm doing wrong, it'd be much appreciated:
>
> size_t SourceFileImplOggVorbis::readFn( void *ptr, size_t size, size_t
> nmemb, void *datasource )
> {
> auto sourceFile = (SourceFileImplOggVorbis *)datasource;
>
> size_t bytes = size * nmemb;
> sourceFile->mStream->readData( ptr, bytes );
>
>  return nmemb;
> }
>
> int SourceFileImplOggVorbis::seekFn( void *datasource, ogg_int64_t offset,
> int whence )
> {
> auto sourceFile = (SourceFileImplOggVorbis *)datasource;
>
> switch( whence ) {
> case SEEK_SET:
> sourceFile->mStream->seekAbsolute( (off_t)offset );
>  break;
> case SEEK_CUR:
> sourceFile->mStream->seekRelative( (off_t)offset );
>  break;
> case SEEK_END:
> sourceFile->mStream->seekAbsolute( (off_t)( - offset ) );
>  break;
> default:
> CI_ASSERT_NOT_REACHABLE();
>  return -1;
> }
>
> return 0;
> }
>
> int SourceFileImplOggVorbis::closeFn( void *datasource )
> {
> return 0;
> }
>
> long SourceFileImplOggVorbis::tellFn( void *datasource )
> {
> auto sourceFile = (SourceFileImplOggVorbis *)datasource;
>
>  long pos = sourceFile->mStream->tell();
>
> return pos;
> }
>
> The source file for this code can also be found here<https://github.com/richardeakin/Cinder-Audio2/blob/85126bdddc69110d6ea8bbd982bc11ff20d536d3/src/cinder/audio2/FileOggVorbis.cpp#L153>
> .
>
> Thanks a ton,
> Rich
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/vorbis/attachments/20140203/008bbe5f/attachment.htm 


More information about the Vorbis mailing list