--- libgig/trunk/src/gig.cpp 2003/10/25 20:15:04 2 +++ libgig/trunk/src/gig.cpp 2003/11/16 17:47:00 11 @@ -323,8 +323,9 @@ * @see SetPos() */ unsigned long Sample::Read(void* pBuffer, unsigned long SampleCount) { - if (!Compressed) return pCkData->Read(pBuffer, SampleCount, FrameSize); + if (!Compressed) return pCkData->Read(pBuffer, SampleCount, FrameSize); //FIXME: channel inversion due to endian correction? else { //FIXME: no support for mono compressed samples yet, are there any? + if (this->SamplePos >= this->SamplesTotal) return 0; //TODO: efficiency: we simply assume here that all frames are compressed, maybe we should test for an average compression rate // best case needed buffer size (all frames compressed) unsigned long assumedsize = (SampleCount << 1) + // *2 (16 Bit, stereo, but assume all frames compressed) @@ -353,8 +354,7 @@ // reload from disk to local buffer if needed if (remainingbytes < 8194) { if (pCkData->GetState() != RIFF::stream_ready) { - this->SamplePos += (SampleCount - remainingsamples); - //if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal; + this->SamplePos = this->SamplesTotal; return (SampleCount - remainingsamples); } assumedsize = remainingsamples; @@ -474,7 +474,7 @@ } } this->SamplePos += (SampleCount - remainingsamples); - //if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal; + if (this->SamplePos > this->SamplesTotal) this->SamplePos = this->SamplesTotal; return (SampleCount - remainingsamples); } }