[vorbis] Channels set to zero?

Ryan Ashley Lord_Dakron at hotmail.com
Fri Feb 20 00:29:19 PST 2004



   I think Windoze was just being retarded.  After I started coding again
tonight (rebooted since last post) I compiled and it doesn't report zero
now.  Had other dumb problems like that as well in the past.  Windows just
isn't Linux, lol!  Then again, neither is X-Win.
   Anyway, I've taken your advice to allocate my buffer, but I'm still
having a problem in the cache function of my OGGDATA class.  The source is
below, so maybe you can see something I'm just over-looking.  I've spent
most of my day working with this, but it just won't work.  When it does
finish, and I play the buffer, I hear a static pop, then nothing.  Upon
exiting and reading the program log (the sLog.Write() stuff) I see a few
things.  here's what the general info reports, the last 'ov_read()' call,
and then my actual function.  Thanks for the help.  Oh and just out of
curiosity, since we currently only have up to 7.1 Dolby, why use an integer
for the number of channels in the 'vorbis_info' structure?  Why not use an
unsigned char since it only uses 1/4 the memory of an integer, and it'll be
a while before humans start using 256 speaker configs :p!  Not trying to be
a dumbazz, I'm just a very resource-concious coder.

Channels: 2
Total: 5292001
Streams: 0
Bitrate: 1
..
================
Read: 1504 bytes
Left: 1 bytes
================
Read: -131 bytes
Left: 132 bytes

pSOUNDDATA OGGDATA::CacheOGGLow()
  {
  unsigned char Channels;
  unsigned int Read;
  ogg_int64_t Total, Location;
  pSOUNDDATA pSndInf;

  if((pSndInf = (pSOUNDDATA)malloc(sizeof(sSOUNDDATA))) == NULL)
    {
    ov_clear(&sOVFile);
    return NULL;
    }

  Channels = 0;
  Total = 0;
  for(int Loop = 0; Loop < sOVFile.links; Loop++)
    {
    if((pOVInfo = ov_info(&sOVFile, Loop)) == NULL)
      {
      ov_clear(&sOVFile);
      free(pSndInf);
      return NULL;
      }

    Channels += pOVInfo->channels;
    Total += ov_pcm_total(&sOVFile, Loop);
    }

  if(Channels < 1)
    {
    MessageBox(NULL, "Zero channels in OGG.\0", "Error\0", MB_OK);
    ov_clear(&sOVFile);
    free(pSndInf);
    return NULL;
    }

  if((pSndInf->Buffer = (char*)malloc(Total * Channels)) == NULL)
    {
    ov_clear(&sOVFile);
    free(pSndInf);
    return NULL;
    }

  pOVInfo = ov_info(&sOVFile, -1);
  sLog.Write("Channels: %i\nTotal: %i\nStreams: %i\nBitrate: %i", Channels,
Total, sOVFile.links, pOVInfo->rate);
  Location = 0;
  for(int Loop = 0; Loop < sOVFile.links; Loop++)
    {
    Total = ov_pcm_total(&sOVFile, Loop);
    while(Total > 0)
      {
      Read = ov_read(&sOVFile, (pSndInf->Buffer + Location), Total, 0, 2, 0,
&Loop);
      Location += Read;
      Total -= Read;
      sLog.Write("================\nRead: %i bytes\nLeft: %i bytes", Read,
Total);
      }
    }

  pSndInf->Frequency = pOVInfo->rate;
  pSndInf->Channels = 0x1103;
  return pSndInf;
  }
--- >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