Beispiel #1
0
void SimpleAudioEngine::preloadEffect(const char* pszFilePath)
{
	int nRet = 0;
	CCAudioOut* pEffectPlayer = NULL;
	do
	{
		BREAK_IF(! pszFilePath);

		string strFilePath = fullPathFromRelativePath(pszFilePath);

		nRet = _Hash(strFilePath.c_str());

		BREAK_IF(s_List.end() != s_List.find(nRet));

		//AppLog("not find effect, create it...");
		if (s_List.size() >= 64)
		{
			// get the first effect, and remove it form list
			//AppLog("effect preload more than 64, delete the first effect");
			pEffectPlayer = s_List.begin()->second;
			pEffectPlayer->Finalize();
			s_List.erase(s_List.begin()->first);
		}
		if (pEffectPlayer == NULL)
			pEffectPlayer = new CCAudioOut;
		pEffectPlayer->Initialize(strFilePath.c_str());

		s_List.insert(Effect(nRet, pEffectPlayer));

	} while (0);
}
	int getId(const string &name) const
	{
		EffectList::const_iterator it = effects.begin();
		for(; it != effects.end(); ++it)
		{
			if(it->name == name)
				return it - effects.begin();
		}

		return -1;
	}
Beispiel #3
0
void SimpleAudioEngine::stopAllEffects()
{
	for (EffectList::iterator it = s_List.begin(); it != s_List.end(); ++it)
	{
		it->second->Stop();
	}
}
Beispiel #4
0
SimpleAudioEngine::~SimpleAudioEngine()
{
	for (EffectList::iterator it = s_List.begin(); it != s_List.end(); ++it)
	{
		it->second->Stop();
		delete it->second;
	}

	s_List.clear();

	closeMediaPlayer(s_pBackPlayer);
	delete s_pBackPlayer;
	s_pBackPlayer = NULL;
}
void QBSoundMac::stopAll()
{
	QBSoundLocker locker(&mMutex,"stopAll");
#ifdef __USE_OGG_VORBIS__
  {
    PlayerList::iterator it = streamTrack.begin();
    while(it != streamTrack.end()) {
      delete (*it).second;
      ++it;
    }
    streamTrack.clear();
  }
  {
    EffectList::iterator it = effectTrack.begin();
    while(it != effectTrack.end())
    {
      delete (*it).second;
      ++it;
    }
    effectTrack.clear();
  }
#endif
	return QBSound::stopAll();
}