/* *---------------------------------------------------------------------------- * buffering (callback) *---------------------------------------------------------------------------- */ static void cbSound(SLAndroidSimpleBufferQueueItf bq, void *context) { if(g_slBufQ) { sndbuf((char*)g_sndBuf,sizeof(g_sndBuf)); (*g_slBufQ)->Enqueue(g_slBufQ,g_sndBuf,sizeof(g_sndBuf)); } }
/* Checks if the soundBuffer corresponding to "key" is loaded or not. If it is loaded, a shared_ptr to the soundBuffer is returned. If it isn't loaded, the resource is loaded and a shared pointer to the soundBuffer is returned. A weak_ptr is then stored in a map, mapping key to the soundBuffer. Se function getTexture for a descirption of each function. */ std::shared_ptr<sf::SoundBuffer> ResourceManager::getSoundBuffer(const std::string &key){ std::map<std::string, std::weak_ptr<sf::SoundBuffer> >::iterator iter; iter = mSoundBufferMap.find(key); if( iter != mSoundBufferMap.end() && !iter->second.expired() ){ return iter->second.lock(); } else{ std::shared_ptr<sf::SoundBuffer> sndbuf (new sf::SoundBuffer); if (!sndbuf->loadFromFile(mFilePath + key)){ assert(false); } mSoundBufferMap.insert(std::pair<std::string, std::weak_ptr<sf::SoundBuffer> >(key, sndbuf) ); return sndbuf; } }