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@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.
> pData->Length = ov_pcm_total(&sOVFile, -1);Total length of all links in file, in samples.> if((pData->Buffer = (char*)malloc(pData->Length)) == NULL)Incorrect. You want to allocate length * channels * bytes_per_sample here, not just length. However, since you're looking at _all_ the links in the file, the number of channels could change.> if(pOVInfo->channels == 1) > pData->Channels = 0x1101; > else > pData->Channels = 0x1103;I doubt that's what you mean - number of channels can be more than 2.> > numStreams = ov_streams(&sOVFile); > StreamID = 0; > Location = 0; > while(StreamID < numStreams) > { > Size = ov_pcm_total(&sOVFile, StreamID);This time you find out the length (in samples) of a particular link in the file. That's good. But the buffer (allocated before) is wrong.> while(Size > 0); > { > Read = ov_read(&sOVFile, (pData->Buffer + Location), Size, 0, 2, 1, > &StreamID); Size -= Read; > Location += Read;Size is in samples (as is Location), Read is in bytes. These are not the same. You also need to look at what StreamID is after each call, so that you can allocate a new buffer (sized appropriately for the number of channels in this link) and start using it. Mike <p>--- >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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.