> Я не слишком силен в C++, но покажите что находится в
> `src/PoolFile/TStaticPoolAccesser.h' на 74-ой и ближайших строках, а
/* !!! NOTE !!!
* It is very important to use this const subscript operator whenever
* the data is being read but not modified. If you use the non-const
* subscript operator it will cause the block to be flagged as dirty
* and the data will be written back to disk even though it did not
* need to be.
*/
74 inline pool_element_t operator[](const l_addr_t where) const
75 {
... if(where>endAddress || where<startAddress)
{
if(poolFile!=NULL)
cacheBlock(where);
else
throw runtime_error(string(__func__)+" const -- CPoolFile object no
longer exists");
}
return cacheBuffer[where-startAddress];
}
> так же в `src/backend/CrezSoundTranslator.cpp' на 356-ой и ближайших
> строках.
bool CrezSoundTranslator::onLoadSound(const string filename,CSound
*sound) const
{
// after the "Format Info" pool is read, these will be populated with
data from the file
sample_pos_t size=0;
Endians endian=eLittleEndian;
unsigned sampleRate=0;
unsigned channelCount=0;
AudioEncodingTypes audioEncodingType;
CSound::PoolFile_t
loadFromFile(REZOUND_POOLFILE_BLOCKSIZE,REZOUND_POOLFILE_SIGNATURE);
loadFromFile.openFile(filename,false); // we could pass a read-only
flag if there was such a thing???
try
{
// read the meta data pool
{
// check version at the beginning of RFormat and perhaps handle
things differently
uint32_t version=0xffffffff;
loadFromFile.readPoolRaw("Format Info",&version,sizeof(version));
lethe(&version);
if(version==1)
{
// read packed version into p
RFormatInfo1::PackedChunk p;
356 loadFromFile.getPoolAccesser<RFormatInfo1::PackedChunk>("Format
Info").read(&p,1);
358 // unpack from p into r
359 RFormatInfo1 r;
... r.unpack(p);
// use values now in r
if(r.size>MAX_LENGTH)
{
// ??? what should I do? truncate the sound or just error out?
}
size=r.size;
endian=eLittleEndian;
sampleRate=r.sampleRate;
channelCount=r.channelCount;
audioEncodingType=aetPCMSigned16BitInteger;
}
else if(version==2)
{
// read packed version into p
RFormatInfo2::PackedChunk p;
loadFromFile.getPoolAccesser<RFormatInfo2::PackedChunk>("Format
Info").read(&p,1);
// unpack from p into r
RFormatInfo2 r;
r.unpack(p);
// use values now in r
if(r.size>MAX_LENGTH)
{
// ??? what should I do? truncate the sound or just error out?
}
size=r.size;
endian=eLittleEndian;
sampleRate=r.sampleRate;
channelCount=r.channelCount;
audioEncodingType=(AudioEncodingTypes)r.audioEncodingType;
}
else if(version==3)
{
// read packed version into p
RFormatInfo3::PackedChunk p;
loadFromFile.getPoolAccesser<RFormatInfo3::PackedChunk>("Format
Info").read(&p,1);
// unpack values from p into r
RFormatInfo3 r;
r.unpack(p);
// use values now in r
if(r.size>MAX_LENGTH)
{
// ??? what should I do? truncate the sound or just error out?
}
size=r.size;
endian=(Endians)r.endian;
sampleRate=r.sampleRate;
channelCount=r.channelCount;
audioEncodingType=(AudioEncodingTypes)r.audioEncodingType;
}
else ...