本文整理汇总了C++中SoundPlayer::GetFileBufferSize方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundPlayer::GetFileBufferSize方法的具体用法?C++ SoundPlayer::GetFileBufferSize怎么用?C++ SoundPlayer::GetFileBufferSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundPlayer
的用法示例。
在下文中一共展示了SoundPlayer::GetFileBufferSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFromFile
int SoundDataManager::loadFromFile(const char* pFilePath)
{
int nSoundID = 0;
do
{
BREAK_IF(! FileUtils::isFileExisted(pFilePath));
int nID = BKDRHash(pFilePath);
// if we have loaded the file before,break
tEffectElement *pElement = NULL;
HASH_FIND_INT(m_pEffects, &nID, pElement);
if (pElement)
{
nSoundID = nID;
break;
}
// calculate the buffer size we needed
SoundPlayer TempPlayer;
int nBufferSize = TempPlayer.GetFileBufferSize(pFilePath);
// can not calculate the size,load failed
BREAK_IF(nBufferSize < 0);
// load the file data
unsigned char* buffer = NULL;
buffer = new unsigned char[nBufferSize];
BREAK_IF(!buffer);
int nSize = TempPlayer.DecodeFile(buffer, nBufferSize, pFilePath);
BREAK_IF(nSize < 0);
// record the id
nSoundID = nID;
// add the data to hash map
pElement = (tEffectElement*)calloc(sizeof(*pElement), 1);
pElement->nSoundID = nSoundID;
pElement->pDataBuffer = buffer;
pElement->nDataSize = nBufferSize;
pElement->FileName = "";
pElement->nPlayerSoundID = -1;
HASH_ADD_INT(m_pEffects, nSoundID, pElement);
} while (0);
return nSoundID;
}