int time_seek(float seconds){
    // translate time to PCM position and call pcm_seek

    int link=-1;
    long pcm_total=pcm_total(-1);
    float time_total=time_total(-1);

    if(!seekable)
      return (-1); // don't dump machine if we can't seek
    if(seconds<0||seconds>time_total){
      //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_total-=pcmlengths[link];
      time_total-=time_total(link);
      if(seconds>=time_total)
        break;
    }

    // enough information to convert time offset to pcm offset
    {
      long target=(long)(pcm_total+(seconds-time_total)*vi[link].rate);
      return (pcm_seek(target));
    }

    //seek_error:
    // dump machine so we're in a known state
    //pcm_offset=-1;
    //decode_clear();
    //return -1;
  }