public synchronized int available()
    throws IOException
  {
    if (!initialised) {
      initialise(false);
      if (!initialised) {
        return 0;
      }
    }
    int avail = super.available();
    if (packetCount >= packetsPerOggPage) { // read new Ogg Page header
      readOggPageHeader();
    }
    // See how much we could decode from the underlying stream.
    if (packetCount < packetsPerOggPage) {
      int undecoded = precount - prepos + in.available();
      int size = packetSizes[packetCount];
      int tempCount = 0;
      while (size < undecoded &&
             packetCount + tempCount < packetsPerOggPage) {
        undecoded -= size;
        avail += 2 * frameSize * framesPerPacket;
        tempCount++;
        size = packetSizes[packetCount + tempCount];
      }
    }
    return avail;
  }