Fixed numerous leaks, especially audio leaks + add debug functions to be able to easily check for audio leaks
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6903 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
1b426216e6
commit
7f97094b87
@ -306,10 +306,20 @@ SFXBase* SFXManager::createSoundSource(SFXBuffer* buffer,
|
||||
sfx->volume(m_master_gain);
|
||||
|
||||
if (add_to_SFX_list) m_all_sfx.push_back(sfx);
|
||||
|
||||
|
||||
return sfx;
|
||||
} // createSoundSource
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
void SFXManager::dump()
|
||||
{
|
||||
for(int n=0; n<(int)m_all_sfx.size(); n++)
|
||||
{
|
||||
printf("Sound %i : %s \n", n, ((SFXOpenAL*)m_all_sfx[n])->getBuffer()->getFileName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SFXBase* SFXManager::createSoundSource(const std::string &name,
|
||||
const bool addToSFXList)
|
||||
|
@ -129,6 +129,9 @@ public:
|
||||
|
||||
/** Called when sound was muted/unmuted */
|
||||
void soundToggled(const bool newValue);
|
||||
|
||||
/** Prints the list of currently loaded sounds to stdout. Useful to debug audio leaks */
|
||||
void dump();
|
||||
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,8 @@ public:
|
||||
virtual SFXManager::SFXStatus getStatus();
|
||||
virtual void onSoundEnabledBack();
|
||||
|
||||
const SFXBuffer* getBuffer() const { return m_soundBuffer; }
|
||||
|
||||
}; // SFXOpenAL
|
||||
|
||||
#endif // HEADER_SFX_OPENAL_HPP
|
||||
|
@ -78,11 +78,12 @@ Explosion::Explosion(const Vec3& coord, const char* explosion_sound)
|
||||
//-----------------------------------------------------------------------------
|
||||
Explosion::~Explosion()
|
||||
{
|
||||
// FIXME LEAK: Explosion that are still playing when a race ends might
|
||||
// not get freed correctly (ssgCutout is removed when removing this
|
||||
// from the scene node).
|
||||
if (m_explode_sound->getStatus() == SFXManager::SFX_PLAYING)
|
||||
{
|
||||
m_explode_sound->stop();
|
||||
}
|
||||
|
||||
sfx_manager->deleteSFX(m_explode_sound);
|
||||
// cut will be cleaned up when the explosion is rerefed by plib
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Explosion::init(const Vec3& coord)
|
||||
|
@ -54,11 +54,12 @@ void ProjectileManager::cleanup()
|
||||
{
|
||||
delete *i;
|
||||
}
|
||||
|
||||
m_active_projectiles.clear();
|
||||
for(Explosions::iterator i = m_active_explosions.begin();
|
||||
i != m_active_explosions.end(); ++i)
|
||||
{
|
||||
// FIXME: still to do
|
||||
delete *i;
|
||||
}
|
||||
|
||||
m_active_explosions.clear();
|
||||
@ -108,10 +109,11 @@ void ProjectileManager::update(float dt)
|
||||
while(e!=m_active_explosions.end())
|
||||
{
|
||||
if(!(*e)->hasEnded()) { e++; continue;}
|
||||
//Explosion *exp=*e;
|
||||
Explosions::iterator eNext=m_active_explosions.erase(e);
|
||||
//ssgDeRefDelete(exp); // reduce refcount and free object
|
||||
e=eNext;
|
||||
|
||||
delete *e;
|
||||
|
||||
Explosions::iterator eNext = m_active_explosions.erase(e);
|
||||
e = eNext;
|
||||
} // while e!=m_active_explosions.end()
|
||||
} // if m_explosion_ended
|
||||
m_something_was_hit=false;
|
||||
|
@ -313,6 +313,7 @@ Kart::~Kart()
|
||||
sfx_manager->deleteSFX(m_crash_sound );
|
||||
sfx_manager->deleteSFX(m_skid_sound );
|
||||
sfx_manager->deleteSFX(m_goo_sound );
|
||||
sfx_manager->deleteSFX(m_beep_sound );
|
||||
if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound);
|
||||
if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
|
||||
if(m_smoke_system) delete m_smoke_system;
|
||||
|
@ -65,6 +65,7 @@ WorldStatus::~WorldStatus()
|
||||
{
|
||||
sfx_manager->deleteSFX(m_prestart_sound);
|
||||
sfx_manager->deleteSFX(m_start_sound);
|
||||
sfx_manager->deleteSFX(m_track_intro_sound);
|
||||
} // ~WorldStatus
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -251,6 +251,9 @@ void RaceManager::startNew()
|
||||
*/
|
||||
void RaceManager::startNextRace()
|
||||
{
|
||||
// Uncomment to debug audio leaks
|
||||
// sfx_manager->dump();
|
||||
|
||||
stk_config->getAllScores(&m_score_for_position, m_num_karts);
|
||||
IrrlichtDevice* device = irr_driver->getDevice();
|
||||
GUIEngine::renderLoading();
|
||||
|
Loading…
x
Reference in New Issue
Block a user