summaryrefslogtreecommitdiffstats
path: root/src/sound
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2014-02-21 10:13:48 +0100
committererihel <erihel@gmail.com>2014-02-21 10:13:48 +0100
commit2433cb595acacf8433405fc9e446757280bd3108 (patch)
tree37a88cc895b7d17a764f9a3037c9423b994ce1ec /src/sound
parentf21ab91184cf5b6a97bc5ae62c49ac8ac68a8b05 (diff)
downloadcolobot-2433cb595acacf8433405fc9e446757280bd3108.tar.gz
colobot-2433cb595acacf8433405fc9e446757280bd3108.tar.bz2
colobot-2433cb595acacf8433405fc9e446757280bd3108.zip
Added a check when trying to play a music file
Diffstat (limited to 'src/sound')
-rw-r--r--src/sound/oalsound/alsound.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index fab0445..ce109e4 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -346,7 +346,7 @@ int ALSound::Play(Sound sound, const Math::Vector &pos, float amplitude, float f
}
if (m_sounds.find(sound) == m_sounds.end())
{
- GetLogger()->Warn("Sound %d was not loaded!\n", sound);
+ GetLogger()->Debug("Sound %d was not loaded!\n", sound);
return -1;
}
@@ -638,21 +638,23 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
std::stringstream file;
file << m_soundPath << "/" << filename;
-
Buffer *buffer;
// check if we have music in cache
if (m_music.find(filename) == m_music.end())
{
- GetLogger()->Warn("Music %s was not cached!\n", filename.c_str());
+ GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
if (!boost::filesystem::exists(file.str()))
{
- GetLogger()->Warn("Requested music %s was not found.\n", filename.c_str());
+ GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
return false;
}
-
+
buffer = new Buffer();
- buffer->LoadFromFile(file.str(), static_cast<Sound>(-1));
+ if (!buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
+ {
+ return false;
+ }
m_music[filename] = buffer;
}
else