<div dir="ltr">Well it looks like I got it working a day later... looks like I had implemented SEEK_END wrong, although I&#39;m not sure why this would lead to the seek_func callback being called infintely.<div><br></div><div>
Apologies for the noise, and thanks for the awesome and free sound file format.</div><div><br></div><div>cheers,</div><div>Rich</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 2, 2014 at 4:54 AM, Rich E <span dir="ltr">&lt;<a href="mailto:reakinator@gmail.com" target="_blank">reakinator@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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 style="white-space:pre-wrap">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div>

<div><br></div><div><span style="white-space:pre-wrap">        </span>size_t bytes = size * nmemb;</div><div><span style="white-space:pre-wrap">        </span>sourceFile-&gt;mStream-&gt;readData( ptr, bytes );</div><div><br></div>
<div><span style="white-space:pre-wrap">        </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 style="white-space:pre-wrap">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div>

<div><br></div><div><span style="white-space:pre-wrap">        </span>switch( whence ) {<br></div><div><span style="white-space:pre-wrap">                </span>case SEEK_SET:</div><div><span style="white-space:pre-wrap">                        </span>sourceFile-&gt;mStream-&gt;seekAbsolute( (off_t)offset );</div>

<div><span style="white-space:pre-wrap">                        </span>break;</div><div><span style="white-space:pre-wrap">                </span>case SEEK_CUR:</div><div><span style="white-space:pre-wrap">                        </span>sourceFile-&gt;mStream-&gt;seekRelative( (off_t)offset );</div>

<div><span style="white-space:pre-wrap">                        </span>break;</div><div><span style="white-space:pre-wrap">                </span>case SEEK_END:</div><div><span style="white-space:pre-wrap">                        </span>sourceFile-&gt;mStream-&gt;seekAbsolute( (off_t)( - offset ) );<br>

</div><div><span style="white-space:pre-wrap">                        </span>break;</div><div><span style="white-space:pre-wrap">                </span>default:</div><div><span style="white-space:pre-wrap">                        </span>CI_ASSERT_NOT_REACHABLE();</div>
<div><span style="white-space:pre-wrap">                        </span>return -1;</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">        </span>return 0;</div><div>}</div>
<div><br></div><div>int<span style="white-space:pre-wrap">        </span>SourceFileImplOggVorbis::closeFn( void *datasource )<br></div><div>{</div><div><span style="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="white-space:pre-wrap">        </span>auto sourceFile = (SourceFileImplOggVorbis *)datasource;</div><div><br>
</div><div><span style="white-space:pre-wrap">        </span>long pos = sourceFile-&gt;mStream-&gt;tell();</div><div><br></div><div><span style="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="https://github.com/richardeakin/Cinder-Audio2/blob/85126bdddc69110d6ea8bbd982bc11ff20d536d3/src/cinder/audio2/FileOggVorbis.cpp#L153" target="_blank">found here</a>.</div>
<div>
<br></div><div>Thanks a ton,</div><div>Rich</div></div>
</blockquote></div><br></div>