From 166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca Mon Sep 17 00:00:00 2001 From: krzys-h Date: Thu, 2 May 2013 16:37:11 +0200 Subject: Improved music cache --- src/sound/oalsound/alsound.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/sound/oalsound') diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index a37cced..ef8ff8d 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -169,17 +169,18 @@ bool ALSound::Cache(Sound sound, std::string filename) bool ALSound::CacheMusic(std::string filename) { - Buffer *buffer = new Buffer(); - std::stringstream file; - file << m_soundPath << "/" << filename; - if (buffer->LoadFromFile(file.str(), static_cast(-1))) { - mMusic[filename] = buffer; - return true; + if(mMusic.find(filename) == mMusic.end()) { + Buffer *buffer = new Buffer(); + std::stringstream file; + file << m_soundPath << "/" << filename; + if (buffer->LoadFromFile(file.str(), static_cast(-1))) { + mMusic[filename] = buffer; + return true; + } } return false; } - int ALSound::GetPriority(Sound sound) { if ( sound == SOUND_FLYh || -- cgit v1.2.3-1-g7c22