if(chunklen > 16) {
if(PHYSFS_seek(file, PHYSFS_tell(file) + (chunklen-16)) == 0)
- throw std::runtime_error("EOF while reading reast of format chunk");
+ throw std::runtime_error("EOF while reading rest of format chunk");
}
// set file offset to DATA chunk data
if(bytes_left_till_loop <= 4)
break;
- if(bytes_left_till_loop < bytes_to_read) {
+ if(bytes_left_till_loop < (ogg_int64_t) bytes_to_read) {
bytes_to_read = (size_t) bytes_left_till_loop;
}
}
music->get("file", raw_music_file);
music->get("loop-begin", loop_begin);
music->get("loop-at", loop_at);
+
+ if(loop_begin < 0) {
+ throw std::runtime_error("can't loop from negative value");
+ }
std::string basedir = FileSystem::dirname(filename);
raw_music_file = FileSystem::normalize(basedir + raw_music_file);
PHYSFS_file* file = PHYSFS_openRead(filename.c_str());
if(!file) {
+ log_warning << "Couldn't open '" << filename << "': " << PHYSFS_getLastError() << ", using dummy sound file." << std::endl;
+ file = PHYSFS_openRead("sounds/empty.wav");
+ if (!file) {
std::stringstream msg;
- msg << "Couldn't open '" << filename << "': " << PHYSFS_getLastError();
- throw std::runtime_error(msg.str());
+ msg << "Couldn't open dummy sound file '" << filename << "': " << PHYSFS_getLastError();
+ throw std::runtime_error(msg.str());
+ }
}
try {
if(strncmp(magic, "RIFF", 4) == 0)
return new WavSoundFile(file);
else if(strncmp(magic, "OggS", 4) == 0)
- return new OggSoundFile(file, -1, 0);
+ return new OggSoundFile(file, 0, -1);
else
throw std::runtime_error("Unknown file format");
} catch(std::exception& e) {