/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by schoenebeck, Sat Oct 25 20:15:04 2003 UTC revision 11 by schoenebeck, Sun Nov 16 17:47:00 2003 UTC
# Line 323  namespace gig { Line 323  namespace gig {
323       * @see                SetPos()       * @see                SetPos()
324       */       */
325      unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) {      unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) {
326          if (!Compressed) return pCkData->Read(pBuffer, SampleCount, FrameSize);          if (!Compressed) return pCkData->Read(pBuffer, SampleCount, FrameSize); //FIXME: channel inversion due to endian correction?
327          else { //FIXME: no support for mono compressed samples yet, are there any?          else { //FIXME: no support for mono compressed samples yet, are there any?
328                if (this->SamplePos >= this->SamplesTotal) return 0;
329              //TODO: efficiency: we simply assume here that all frames are compressed, maybe we should test for an average compression rate              //TODO: efficiency: we simply assume here that all frames are compressed, maybe we should test for an average compression rate
330              // best case needed buffer size (all frames compressed)              // best case needed buffer size (all frames compressed)
331              unsigned long assumedsize      = (SampleCount << 1)  + // *2 (16 Bit, stereo, but assume all frames compressed)              unsigned long assumedsize      = (SampleCount << 1)  + // *2 (16 Bit, stereo, but assume all frames compressed)
# Line 353  namespace gig { Line 354  namespace gig {
354                  // reload from disk to local buffer if needed                  // reload from disk to local buffer if needed
355                  if (remainingbytes < 8194) {                  if (remainingbytes < 8194) {
356                      if (pCkData->GetState() != RIFF::stream_ready) {                      if (pCkData->GetState() != RIFF::stream_ready) {
357                          this->SamplePos += (SampleCount - remainingsamples);                          this->SamplePos = this->SamplesTotal;
                         //if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal;  
358                          return (SampleCount - remainingsamples);                          return (SampleCount - remainingsamples);
359                      }                      }
360                      assumedsize    = remainingsamples;                      assumedsize    = remainingsamples;
# Line 474  namespace gig { Line 474  namespace gig {
474                  }                  }
475              }              }
476              this->SamplePos += (SampleCount - remainingsamples);              this->SamplePos += (SampleCount - remainingsamples);
477              //if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal;              if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal;
478              return (SampleCount - remainingsamples);              return (SampleCount - remainingsamples);
479          }          }
480      }      }

Legend:
Removed from v.2  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC