mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 05:45:33 +00:00
Remove some unnecessary wrappers and do some small cleanups
This commit is contained in:
parent
a91085a1b9
commit
a69ec91242
2 changed files with 28 additions and 42 deletions
|
@ -78,8 +78,6 @@ namespace MWSound
|
||||||
{
|
{
|
||||||
LooseSounds.clear();
|
LooseSounds.clear();
|
||||||
ActiveSounds.clear();
|
ActiveSounds.clear();
|
||||||
if(mMusic)
|
|
||||||
mMusic->Stop();
|
|
||||||
mMusic.reset();
|
mMusic.reset();
|
||||||
Output.reset();
|
Output.reset();
|
||||||
}
|
}
|
||||||
|
@ -135,32 +133,10 @@ namespace MWSound
|
||||||
}
|
}
|
||||||
catch(std::exception &e)
|
catch(std::exception &e)
|
||||||
{
|
{
|
||||||
std::cout <<"Sound play error: "<<e.what()<< std::endl;
|
std::cout <<"Sound Error: "<<e.what()<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop a sound and remove it from the list. If id="" then
|
|
||||||
// remove the entire object and stop all its sounds.
|
|
||||||
void SoundManager::remove(MWWorld::Ptr ptr, const std::string &id)
|
|
||||||
{
|
|
||||||
SoundMap::iterator snditer = ActiveSounds.find(ptr);
|
|
||||||
if(snditer == ActiveSounds.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if(!id.empty())
|
|
||||||
{
|
|
||||||
IDMap::iterator iditer = snditer->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
|
bool SoundManager::isPlaying(MWWorld::Ptr ptr, const std::string &id) const
|
||||||
{
|
{
|
||||||
SoundMap::const_iterator snditer = ActiveSounds.find(ptr);
|
SoundMap::const_iterator snditer = ActiveSounds.find(ptr);
|
||||||
|
@ -174,18 +150,6 @@ namespace MWSound
|
||||||
return iditer->second->isPlaying();
|
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()
|
void SoundManager::stopMusic()
|
||||||
{
|
{
|
||||||
|
@ -194,7 +158,6 @@ namespace MWSound
|
||||||
setPlaylist();
|
setPlaylist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SoundManager::streamMusicFull(const std::string& filename)
|
void SoundManager::streamMusicFull(const std::string& filename)
|
||||||
{
|
{
|
||||||
if(mMusic)
|
if(mMusic)
|
||||||
|
@ -337,12 +300,37 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::stopSound3D(MWWorld::Ptr ptr, const std::string& soundId)
|
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)
|
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)
|
void SoundManager::stopSound(const std::string& soundId)
|
||||||
|
|
|
@ -64,9 +64,7 @@ namespace MWSound
|
||||||
MWWorld::Ptr ptr, const std::string &id,
|
MWWorld::Ptr ptr, const std::string &id,
|
||||||
float volume, float pitch, float min, float max,
|
float volume, float pitch, float min, float max,
|
||||||
bool loop, bool untracked=false);
|
bool loop, bool untracked=false);
|
||||||
void remove(MWWorld::Ptr ptr, const std::string &id = "");
|
|
||||||
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
|
bool isPlaying(MWWorld::Ptr ptr, const std::string &id) const;
|
||||||
void removeCell(const MWWorld::Ptr::CellStore *cell);
|
|
||||||
void updateRegionSound(float duration);
|
void updateRegionSound(float duration);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue