Added a check when trying to play a music file
parent
f21ab91184
commit
2433cb595a
|
@ -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())
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,21 +638,23 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
|
||||||
|
|
||||||
std::stringstream file;
|
std::stringstream file;
|
||||||
file << m_soundPath << "/" << filename;
|
file << m_soundPath << "/" << filename;
|
||||||
|
|
||||||
Buffer *buffer;
|
Buffer *buffer;
|
||||||
|
|
||||||
// check if we have music in cache
|
// check if we have music in cache
|
||||||
if (m_music.find(filename) == m_music.end())
|
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()))
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = new Buffer();
|
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;
|
m_music[filename] = buffer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue