From 2433cb595acacf8433405fc9e446757280bd3108 Mon Sep 17 00:00:00 2001 From: erihel Date: Fri, 21 Feb 2014 10:13:48 +0100 Subject: Added a check when trying to play a music file --- src/sound/oalsound/alsound.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/sound/oalsound') 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(-1)); + if (!buffer->LoadFromFile(file.str(), static_cast(-1))) + { + return false; + } m_music[filename] = buffer; } else -- cgit v1.2.3-1-g7c22