diff --git a/apps/openmw/mwsound/soundmanager.cpp b/apps/openmw/mwsound/soundmanager.cpp index 5d872476e..5b050e612 100644 --- a/apps/openmw/mwsound/soundmanager.cpp +++ b/apps/openmw/mwsound/soundmanager.cpp @@ -78,8 +78,6 @@ namespace MWSound { LooseSounds.clear(); ActiveSounds.clear(); - if(mMusic) - mMusic->Stop(); mMusic.reset(); Output.reset(); } @@ -135,32 +133,10 @@ namespace MWSound } catch(std::exception &e) { - std::cout <<"Sound play error: "<second.find(id); - if(iditer != snditer->second.end()) - { - snditer->second.erase(iditer); - if(snditer->second.size() == 0) - ActiveSounds.erase(snditer); - } - } - else - ActiveSounds.erase(snditer); - } - bool SoundManager::isPlaying(MWWorld::Ptr ptr, const std::string &id) const { SoundMap::const_iterator snditer = ActiveSounds.find(ptr); @@ -174,18 +150,6 @@ namespace MWSound return iditer->second->isPlaying(); } - // Remove all references to objects belonging to a given cell - void SoundManager::removeCell(const MWWorld::Ptr::CellStore *cell) - { - SoundMap::iterator snditer = ActiveSounds.begin(); - while(snditer != ActiveSounds.end()) - { - if(snditer->first.getCell() == cell) - ActiveSounds.erase(snditer++); - else - snditer++; - } - } void SoundManager::stopMusic() { @@ -194,7 +158,6 @@ namespace MWSound setPlaylist(); } - void SoundManager::streamMusicFull(const std::string& filename) { if(mMusic) @@ -337,12 +300,37 @@ namespace MWSound void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId) { - remove(ptr, soundId); + // Stop a sound and remove it from the list. If soundId="" then + // stop all its sounds. + SoundMap::iterator snditer = ActiveSounds.find(ptr); + if(snditer == ActiveSounds.end()) + return; + + if(!soundId.empty()) + { + IDMap::iterator iditer = snditer->second.find(soundId); + if(iditer != snditer->second.end()) + { + snditer->second.erase(iditer); + if(snditer->second.size() == 0) + ActiveSounds.erase(snditer); + } + } + else + ActiveSounds.erase(snditer); } void SoundManager::stopSound(MWWorld::Ptr::CellStore *cell) { - removeCell(cell); + // Remove all references to objects belonging to a given cell + SoundMap::iterator snditer = ActiveSounds.begin(); + while(snditer != ActiveSounds.end()) + { + if(snditer->first.getCell() == cell) + ActiveSounds.erase(snditer++); + else + snditer++; + } } void SoundManager::stopSound(const std::string& soundId) diff --git a/apps/openmw/mwsound/soundmanager.hpp b/apps/openmw/mwsound/soundmanager.hpp index df7e696da..62e452cde 100644 --- a/apps/openmw/mwsound/soundmanager.hpp +++ b/apps/openmw/mwsound/soundmanager.hpp @@ -64,9 +64,7 @@ namespace MWSound MWWorld::Ptr ptr, const std::string &id, float volume, float pitch, float min, float max, bool loop, bool untracked=false); - void remove(MWWorld::Ptr ptr, const std::string &id = ""); bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const; - void removeCell(const MWWorld::Ptr::CellStore *cell); void updateRegionSound(float duration); public: