Logo Search packages:      
Sourcecode: catcodec version File versions  Download package

void Sample::ReadCatEntry ( FileReader reader,
bool  new_format 

Reads a cat entry from a reader. This function has some very strict tests on validity of the input file.

readerplace to read the cat entry from
new_formatwhether this is the old or new format; there are different strictness tests for both cases

Definition at line 150 of file sample.cpp.

References bits_per_sample, filename, FileReader::GetFilename(), GetName(), GetOffset(), FileReader::GetPos(), name, num_channels, FileReader::ReadByte(), FileReader::ReadRaw(), ReadSample(), ReadString(), RIFF_HEADER_SIZE, sample_data, sample_rate, sample_size, and size.

      assert(this->sample_data == NULL);

      if (reader.GetPos() != this->GetOffset()) throw "Invalid offset in file " + reader.GetFilename();

      this->name = ReadString(reader);

      if (!new_format && this->GetName().compare("Corrupt sound") == 0) {
            /* In the old format there was one sample that was raw PCM. */
            this->sample_size     = this->size;
            this->sample_data     = (uint8_t *)malloc(this->sample_size);
            reader.ReadRaw(this->sample_data, this->sample_size);

            this->size += RIFF_HEADER_SIZE;
      } else {

      if (!new_format) {
            /* The old format had sometimes the wrong values for e.g.
             * sample rate which made the playback too fast. */
            this->num_channels    = 1;
            this->sample_rate     = 11025;
            this->bits_per_sample = 8;

      /* Some kind of data byte, unused */

      this->filename = ReadString(reader);

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index