projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switched magnification to percentage, added black-border as alternative to scale
[supertux.git]
/
src
/
audio
/
sound_file.cpp
diff --git
a/src/audio/sound_file.cpp
b/src/audio/sound_file.cpp
index
a9e61e7
..
98a615b
100644
(file)
--- a/
src/audio/sound_file.cpp
+++ b/
src/audio/sound_file.cpp
@@
-272,7
+272,7
@@
OggSoundFile::read(void* _buffer, size_t buffer_size)
if(bytes_left_till_loop <= 4)
break;
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;
}
}
bytes_to_read = (size_t) bytes_left_till_loop;
}
}
@@
-371,6
+371,10
@@
SoundFile* load_music_file(const std::string& filename)
music->get("file", raw_music_file);
music->get("loop-begin", loop_begin);
music->get("loop-at", loop_at);
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);
std::string basedir = FileSystem::dirname(filename);
raw_music_file = FileSystem::normalize(basedir + raw_music_file);
@@
-394,9
+398,13
@@
SoundFile* load_sound_file(const std::string& filename)
PHYSFS_file* file = PHYSFS_openRead(filename.c_str());
if(!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;
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 {
}
try {
@@
-407,7
+415,7
@@
SoundFile* load_sound_file(const std::string& filename)
if(strncmp(magic, "RIFF", 4) == 0)
return new WavSoundFile(file);
else if(strncmp(magic, "OggS", 4) == 0)
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) {
else
throw std::runtime_error("Unknown file format");
} catch(std::exception& e) {