Пример #1
0
	void SoundEmitter::setSoundClip(SoundClipPtr soundClip) {
		// equal clip
		if (m_soundClipId == soundClip->getHandle()) {
			return;
		}

		detachSoundClip();
		m_soundClipId = soundClip->getHandle();
		m_soundClip = soundClip;

		attachSoundClip();
	}
Пример #2
0
	void SoundClipManager::remove(SoundClipPtr& resource) {
		SoundClipHandleMapIterator it = m_sclipHandleMap.find(resource->getHandle());
		SoundClipNameMapIterator nit = m_sclipNameMap.find(resource->getName());

		if (it != m_sclipHandleMap.end()) {
			m_sclipHandleMap.erase(it);

			if (nit != m_sclipNameMap.end()) {
				m_sclipNameMap.erase(nit);
				return;
			}
			assert(false); //should never get here
		}

		FL_WARN(_log, LMsg("SoundClipManager::remove(ResourcePtr&) - ") << "Resource " << resource->getName() << " was not found.");
	}
Пример #3
0
	SoundClipPtr SoundClipManager::load(const std::string& name, IResourceLoader* loader) {
		SoundClipNameMapIterator nit = m_sclipNameMap.find(name);

		if (nit != m_sclipNameMap.end()) {
			if ( nit->second->getState() == IResource::RES_NOT_LOADED ) {
				nit->second->load();
			}

			return nit->second;
		}

		//was not found so create and load resource
		SoundClipPtr ptr = create(name, loader);
		ptr->load();

		if (ptr->getState() == IResource::RES_NOT_LOADED){
			FL_WARN(_log, LMsg("SoundClipManager::load(std::string) - ") << "Resource name " << name << " was not found and could not be loaded.");
			remove(name);
		}

		return ptr;
	}