[vorbis] Precache an entire OGG?

Ryan Ashley Lord_Dakron at hotmail.com
Wed Feb 18 22:33:20 PST 2004



OK, thanks to the help of another forum user, I got my app compiled and working, but I now need to precache the OGG to memory.  My current method somehow winds up in a loop or freezes the application.  Here is y source for the decode/precache function.  Why is it just freezing?  I've let it run for about three minutes, thinking it was doing some heavy decoding, but I was wrong.  Once this is fixed I'll release this player.  Thanks for the help!

pSOUNDDATA OGGDATA::DecodeOGGLow()
  {
  int StreamID;
  unsigned int Size, Read;
  unsigned int Location, numStreams;
  pSOUNDDATA pData;

  if(pFile == NULL)
    return NULL;

  if((pData = (pSOUNDDATA)malloc(sizeof(sSOUNDDATA))) == NULL)
    return NULL;

  pData->Length = ov_pcm_total(&sOVFile, -1);
  if((pData->Buffer = (char*)malloc(pData->Length)) == NULL)
    {
    free(pData);
    return NULL;
    }

  pOVInfo = ov_info(&sOVFile, -1);
  pData->Frequency = pOVInfo->rate;
  if(pOVInfo->channels == 1)
    pData->Channels = 0x1101;
  else
    pData->Channels = 0x1103;

  numStreams = ov_streams(&sOVFile);
  StreamID = 0;
  Location = 0;
  while(StreamID < numStreams)
    {
    Size = ov_pcm_total(&sOVFile, StreamID);
    while(Size > 0);
      {
      Read = ov_read(&sOVFile, (pData->Buffer + Location), Size, 0, 2, 1, &StreamID);
      Size -= Read;
      Location += Read;
      }
    }

  ov_clear(&sOVFile);
  return pData;
  }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis mailing list