public int raw_seek(int pos){
    if(!seekable)
      return (-1); // don't dump machine if we can't seek
    if(pos<0||pos>offsets[links]){
      //goto seek_error;
      pcm_offset=-1;
      decode_clear();
      return -1;
    }

    // clear out decoding machine state
    pcm_offset=-1;
    decode_clear();

    // seek
    seek_helper(pos);

    // we need to make sure the pcm_offset is set.  We use the
    // _fetch_packet helper to process one packet with readp set, then
    // call it until it returns '0' with readp not set (the last packet
    // from a page has the 'granulepos' field set, and that's how the
    // helper updates the offset

    switch(process_packet(1)){
      case 0:
        // oh, eof. There are no packets remaining.  Set the pcm offset to
        // the end of file
        pcm_offset=pcm_total(-1);
        return (0);
      case -1:
        // error! missing data or invalid bitstream structure
        //goto seek_error;
        pcm_offset=-1;
        decode_clear();
        return -1;
      default:
        // all OK
        break;
    }
    while(true){
      switch(process_packet(0)){
        case 0:
          // the offset is set.  If it's a bogus bitstream with no offset
          // information, it's not but that's not our fault.  We still run
          // gracefully, we're just missing the offset
          return (0);
        case -1:
          // error! missing data or invalid bitstream structure
          //goto seek_error;
          pcm_offset=-1;
          decode_clear();
          return -1;
        default:
          // continue processing packets
          break;
      }
    }

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