mOggStream.datasource = 0;
}
- std::string path = Sound::getPath(name);
- int result = ov_fopen((char*)path.c_str(), &mOggStream);
+ std::string path(name);
+ if (!Sound::getPath(path))
+ {
+ Error(Error::RESOURCE_NOT_FOUND, path).raise();
+ }
- if (result < 0)
+ if (ov_fopen((char*)path.c_str(), &mOggStream) < 0)
{
- logWarning << "couldn't load sound: " << path << std::endl;
Error(Error::UNKNOWN_AUDIO_FORMAT, path).raise();
}
}
-std::string Sound::getPath(const std::string& name)
+bool Sound::getPath(std::string& name)
{
- if (boost::find_last(name, ".ogg"))
- {
- return Resource::getPath(name);
- }
- else
- {
- std::string path("sounds/");
- path += name;
- path += ".ogg";
- return Resource::getPath(path);
- }
+ return Resource::getPath(name, "sounds/", "ogg");
}