本文整理汇总了C++中CIFile::setCacheFileOnOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ CIFile::setCacheFileOnOpen方法的具体用法?C++ CIFile::setCacheFileOnOpen怎么用?C++ CIFile::setCacheFileOnOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIFile
的用法示例。
在下文中一共展示了CIFile::setCacheFileOnOpen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playSync
/// Play from memory.
bool CMusicChannelFMod::playSync(const std::string &filepath, bool loop)
{
CIFile ifile;
ifile.allowBNPCacheFileOnOpen(false);
ifile.setCacheFileOnOpen(false);
ifile.open(filepath);
// try to load the music in memory
uint32 fs = ifile.getFileSize();
if (!fs) {
nlwarning("NLSOUND FMod Driver: Empty music file");
return false;
}
// read Buffer
nlassert(!_MusicBuffer);
_MusicBuffer = new uint8[fs];
try {
ifile.serialBuffer(_MusicBuffer, fs);
}
catch (...)
{
nlwarning("NLSOUND FMod Driver: Error while reading music file");
delete[] _MusicBuffer;
_MusicBuffer = NULL;
return false;
}
// open FMOD stream
_MusicStream = FSOUND_Stream_Open((const char*)_MusicBuffer,
FSOUND_2D | FSOUND_LOADMEMORY | (loop ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF), 0, fs);
if (!_MusicStream)
{
nlwarning("NLSOUND FMod Driver: Error while creating the FMOD stream for music file");
delete[] _MusicBuffer;
_MusicBuffer = NULL;
return false;
}
if (!playStream())
{
nlwarning("NLSOUND FMod Driver: Error While trying to play sync music file");
FSOUND_Stream_Close(_MusicStream);
_MusicStream = NULL;
delete[] _MusicBuffer;
_MusicBuffer = NULL;
return false;
}
return true;
}
示例2: init
// ***************************************************************************
bool CInstanceGroupUser::init (const std::string &instanceGroup, bool async)
{
// Create a file
CIFile file;
if(async)
{
file.setAsyncLoading(true);
file.setCacheFileOnOpen(true);
}
std::string path = CPath::lookup (instanceGroup, false);
if (!path.empty() && file.open (path))
{
// Serialize this class
try
{
// Read the class
_InstanceGroup.serial (file);
}
catch (const EStream& e)
{
// Avoid visual warning
EStream ee=e;
// Serial problem
return false;
}
}
else
{
// Failed.
return false;
}
// Ok
return true;
}