EffectRef SoundEngine::loadEffect(InputSourceRef inputSource) { FMOD_RESULT result = FMOD_OK; FMOD::Sound *sound = NULL; if (inputSource->isFile()) { result = system->createSound(inputSource->getFilePath().c_str(), FMOD_DEFAULT, NULL, &sound); } else { auto buffer = inputSource->loadDataSource()->getBuffer(); FMOD_CREATESOUNDEXINFO exinfo; memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.length = buffer.getDataSize(); result = system->createSound(static_cast<const char*>(buffer.getData()), FMOD_DEFAULT | FMOD_OPENMEMORY, &exinfo, &sound); } if (result) { throw FMODException(result); } else { return make_shared<Effect>(inputSource, sound); } }
void XFont::read(InputSourceRef inputSource) { if (inputSource->isFile()) { ifstream in(inputSource->getFilePath().c_str(), ifstream::binary); readFromStream(in); in.close(); } else { DataSourceRef resource = inputSource->loadDataSource(); Buffer &buffer = resource->getBuffer(); ReadStreamBuffer tmp(buffer); istream in(&tmp); readFromStream(in); } }
FollowablePath::FollowablePath(InputSourceRef inputSource, int mode) : mode(mode) { if (inputSource->isFile()) { ifstream in(inputSource->getFilePath().c_str(), ifstream::binary); readFromStream(in); in.close(); } else { DataSourceRef resource = inputSource->loadDataSource(); Buffer &buffer = resource->getBuffer(); ReadStreamBuffer tmp(buffer); istream in(&tmp); readFromStream(in); } }