Re: Trouble implementing ov_callbacks, endless loop calling seek_func
Rich E <[email protected]> Mon, 3 Feb 2014 03:43:26 -0500
| Newsgroups | gmane.comp.multimedia.ogg.vorbis.general |
|---|---|
| Message-ID | <CA+vnWEgWCOf38QggON7TbCECJktma6-TDvqTbkscPUh9UOvinw@mail.gmail.com> |
--===============0509133189== Content-Type: multipart/alternative; boundary=047d7bd6c70a6b25ca04f17c84f7 --047d7bd6c70a6b25ca04f17c84f7 Content-Type: text/plain; charset=ISO-8859-1 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 <[email protected]> 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 > --047d7bd6c70a6b25ca04f17c84f7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Well it looks like I got it working a day later... looks l= ike I had implemented SEEK_END wrong, although I'm not sure why this wo= uld lead to the seek_func callback being called infintely.<div><br></div><d= iv> Apologies for the noise, and thanks for the awesome and free sound file for= mat.</div><div><br></div><div>cheers,</div><div>Rich</div></div><div class= =3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Sun, Feb 2, 2014 at = 4:54 AM, Rich E <span dir=3D"ltr"><<a href=3D"mailto:[email protected]= m" target=3D"_blank">[email protected]</a>></span> wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello list,<div><br></div><= div>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.</div> <div><br></div><div>I'm hoping it is something obvious, but I can't= see why my seek_func is being called endlessly. =A0If the file is seekable= , I should return 0, right? If any one can take a look at the following cal= lback functions and see if they can spot what I'm doing wrong, it'd= be much appreciated:</div> <div><br></div><div><div>size_t SourceFileImplOggVorbis::readFn( void *ptr,= size_t size, size_t nmemb, void *datasource )<br></div><div>{</div><div><s= pan style=3D"white-space:pre-wrap"> </span>auto sourceFile =3D (SourceFileI= mplOggVorbis *)datasource;</div> <div><br></div><div><span style=3D"white-space:pre-wrap"> </span>size_t byt= es =3D size * nmemb;</div><div><span style=3D"white-space:pre-wrap"> </span= >sourceFile->mStream->readData( ptr, bytes );</div><div><br></div> <div><span style=3D"white-space:pre-wrap"> </span>return nmemb;</div><div>}= </div><div><br></div><div>int SourceFileImplOggVorbis::seekFn( void *dataso= urce, ogg_int64_t offset, int whence )<br></div><div>{</div><div><span styl= e=3D"white-space:pre-wrap"> </span>auto sourceFile =3D (SourceFileImplOggVo= rbis *)datasource;</div> <div><br></div><div><span style=3D"white-space:pre-wrap"> </span>switch( wh= ence ) {<br></div><div><span style=3D"white-space:pre-wrap"> </span>case S= EEK_SET:</div><div><span style=3D"white-space:pre-wrap"> </span>sourceFil= e->mStream->seekAbsolute( (off_t)offset );</div> <div><span style=3D"white-space:pre-wrap"> </span>break;</div><div><span = style=3D"white-space:pre-wrap"> </span>case SEEK_CUR:</div><div><span styl= e=3D"white-space:pre-wrap"> </span>sourceFile->mStream->seekRelativ= e( (off_t)offset );</div> <div><span style=3D"white-space:pre-wrap"> </span>break;</div><div><span = style=3D"white-space:pre-wrap"> </span>case SEEK_END:</div><div><span styl= e=3D"white-space:pre-wrap"> </span>sourceFile->mStream->seekAbsolut= e( (off_t)( - offset ) );<br> </div><div><span style=3D"white-space:pre-wrap"> </span>break;</div><div>= <span style=3D"white-space:pre-wrap"> </span>default:</div><div><span styl= e=3D"white-space:pre-wrap"> </span>CI_ASSERT_NOT_REACHABLE();</div> <div><span style=3D"white-space:pre-wrap"> </span>return -1;</div><div><s= pan style=3D"white-space:pre-wrap"> </span>}</div><div><br></div><div><span= style=3D"white-space:pre-wrap"> </span>return 0;</div><div>}</div> <div><br></div><div>int<span style=3D"white-space:pre-wrap"> </span>SourceF= ileImplOggVorbis::closeFn( void *datasource )<br></div><div>{</div><div><sp= an style=3D"white-space:pre-wrap"> </span>return 0;</div><div>}</div> <div><br></div><div>long SourceFileImplOggVorbis::tellFn( void *datasource = )<br></div><div>{</div><div><span style=3D"white-space:pre-wrap"> </span>au= to sourceFile =3D (SourceFileImplOggVorbis *)datasource;</div><div><br> </div><div><span style=3D"white-space:pre-wrap"> </span>long pos =3D source= File->mStream->tell();</div><div><br></div><div><span style=3D"white-= space:pre-wrap"> </span>return pos;<br></div><div>}</div></div><div><br> </div><div>The source file for this code can also be <a href=3D"https://git= hub.com/richardeakin/Cinder-Audio2/blob/85126bdddc69110d6ea8bbd982bc11ff20d= 536d3/src/cinder/audio2/FileOggVorbis.cpp#L153" target=3D"_blank">found her= e</a>.</div> <div> <br></div><div>Thanks a ton,</div><div>Rich</div></div> </blockquote></div><br></div> --047d7bd6c70a6b25ca04f17c84f7-- --===============0509133189== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Vorbis mailing list [email protected] http://lists.xiph.org/mailman/listinfo/vorbis --===============0509133189==--