+ unsigned int time_start;
+ ogg_int64_t ogg_start;
+ int err;
+
+ if (real_start > sfx->total_length)
+ {
+ Con_Printf ("OGG_FetchSound: asked for a start position after the end of the sfx! (%u > %u)\n",
+ real_start, sfx->total_length);
+ return NULL;
+ }
+
+ // We work with 200ms (1/5 sec) steps to avoid rounding errors
+ time_start = real_start * 5 / snd_renderbuffer->format.speed;
+ ogg_start = time_start * (per_sfx->format.speed / 5);
+ err = qov_pcm_seek (&per_ch->vf, ogg_start);
+ if (err != 0)
+ {
+ Con_Printf ("OGG_FetchSound: qov_pcm_seek(..., %d) returned %d\n",
+ real_start, err);
+ return NULL;
+ }
+ sb->nbframes = 0;
+
+ real_start = (float)ogg_start / per_sfx->format.speed * snd_renderbuffer->format.speed;
+ if (*start - real_start + nbsampleframes > sb->maxframes)
+ {
+ Con_Printf ("OGG_FetchSound: stream buffer too small after seek (%u sample frames required)\n",
+ *start - real_start + nbsampleframes);
+ per_ch->sb_offset = real_start;