<div dir="ltr">Hello list,<div><br></div><div>I&#39;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&#39;t ever return and repeatedly calls my seek_func.</div>
<div><br></div><div>I&#39;m hoping it is something obvious, but I can&#39;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&#39;m doing wrong, it&#39;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><span class="" style="white-space:pre">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div>
<div><br></div><div><span class="" style="white-space:pre">        </span>size_t bytes = size * nmemb;</div><div><span class="" style="white-space:pre">        </span>sourceFile-&gt;mStream-&gt;readData( ptr, bytes );</div><div><br></div>
<div><span class="" style="white-space:pre">        </span>return nmemb;</div><div>}</div><div><br></div><div>int SourceFileImplOggVorbis::seekFn( void *datasource, ogg_int64_t offset, int whence )<br></div><div>{</div><div><span class="" style="white-space:pre">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div>
<div><br></div><div><span class="" style="white-space:pre">        </span>switch( whence ) {<br></div><div><span class="" style="white-space:pre">                </span>case SEEK_SET:</div><div><span class="" style="white-space:pre">                        </span>sourceFile-&gt;mStream-&gt;seekAbsolute( (off_t)offset );</div>
<div><span class="" style="white-space:pre">                        </span>break;</div><div><span class="" style="white-space:pre">                </span>case SEEK_CUR:</div><div><span class="" style="white-space:pre">                        </span>sourceFile-&gt;mStream-&gt;seekRelative( (off_t)offset );</div>
<div><span class="" style="white-space:pre">                        </span>break;</div><div><span class="" style="white-space:pre">                </span>case SEEK_END:</div><div><span class="" style="white-space:pre">                        </span>sourceFile-&gt;mStream-&gt;seekAbsolute( (off_t)( - offset ) );<br>
</div><div><span class="" style="white-space:pre">                        </span>break;</div><div><span class="" style="white-space:pre">                </span>default:</div><div><span class="" style="white-space:pre">                        </span>CI_ASSERT_NOT_REACHABLE();</div>
<div><span class="" style="white-space:pre">                        </span>return -1;</div><div><span class="" style="white-space:pre">        </span>}</div><div><br></div><div><span class="" style="white-space:pre">        </span>return 0;</div><div>}</div>
<div><br></div><div>int<span class="" style="white-space:pre">        </span>SourceFileImplOggVorbis::closeFn( void *datasource )<br></div><div>{</div><div><span class="" style="white-space:pre">        </span>return 0;</div><div>}</div>
<div><br></div><div>long SourceFileImplOggVorbis::tellFn( void *datasource )<br></div><div>{</div><div><span class="" style="white-space:pre">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div><div><br>
</div><div><span class="" style="white-space:pre">        </span>long pos = sourceFile-&gt;mStream-&gt;tell();</div><div><br></div><div><span class="" style="white-space:pre">        </span>return pos;<br></div><div>}</div></div><div><br>
</div><div>The source file for this code can also be <a href="https://github.com/richardeakin/Cinder-Audio2/blob/85126bdddc69110d6ea8bbd982bc11ff20d536d3/src/cinder/audio2/FileOggVorbis.cpp#L153">found here</a>.</div><div>
<br></div><div>Thanks a ton,</div><div>Rich</div></div>