public int time_seek(float seconds)
{
// translate time to PCM position and call pcm_seek
int link=-1;
long pcm_tot=pcm_total(-1);
float time_tot=time_total(-1);
if(!skable)return(-1); // don't dump machine if we can't seek
if(seconds<0 || seconds>time_tot)
{
//goto seek_error;
pcm_offset=-1;
decode_clear();
return -1;
}
// which bitstream section does this time offset occur in?
for(link=links-1;link>=0;link--)
{
pcm_tot-=pcmlengths[link];
time_tot-=time_total(link);
if(seconds>=time_tot)break;
}
// enough information to convert time offset to pcm offset
{
long target=(long)(pcm_tot+(seconds-time_tot)*vi[link].rate);
return(pcm_seek(target));
}
}