Fixed: Crash on exit caused by incomplete music channel reset

This commit is contained in:
kaetemi 2012-04-13 23:30:35 +02:00
parent e3d538198b
commit 491eee49e4
3 changed files with 32 additions and 1 deletions

View file

@ -230,6 +230,8 @@ public:
virtual uint getSourcesInstanceCount() const { return (uint)_Sources.size(); }
/// Return the number of playing sources (slow)
virtual uint getPlayingSourcesCount() const;
uint countPlayingSimpleSources() const; // debug
uint countSimpleSources() const; // debug
/// Return the number of available tracks
virtual uint getAvailableTracksCount() const;
/// Return the number of used tracks

View file

@ -221,6 +221,7 @@ void CAudioMixerUser::writeProfile(std::string& out)
*/
out += "Sound mixer: \n";
out += "\tPlaying sources: " + toString (getPlayingSourcesCount()) + " \n";
out += "\tPlaying simple sources: " + toString(countPlayingSimpleSources()) + " / " + toString(countSimpleSources()) + " \n";
out += "\tAvailable tracks: " + toString (getAvailableTracksCount()) + " \n";
out += "\tUsed tracks: " + toString (getUsedTracksCount()) + " \n";
// out << "\tMuted sources: " << nb << " \n";
@ -270,7 +271,8 @@ void CAudioMixerUser::reset()
_SourceWaitingForPlay.clear();
_MusicChannelFaders->reset();
for (uint i = 0; i < _NbMusicChannelFaders; ++i)
_MusicChannelFaders[i].reset();
// Stop tracks
uint i;
@ -2173,6 +2175,32 @@ uint CAudioMixerUser::getPlayingSourcesCount() const
return _PlayingSources;
}
// ******************************************************************
uint CAudioMixerUser::countPlayingSimpleSources() const
{
uint count = 0;
for (TSourceContainer::const_iterator it(_Sources.begin()), end(_Sources.end()); it != end; ++it)
{
if ((*it)->getType() == CSourceCommon::SOURCE_SIMPLE && (*it)->isPlaying())
++count;
}
return count;
}
uint CAudioMixerUser::countSimpleSources() const
{
uint count = 0;
for (TSourceContainer::const_iterator it(_Sources.begin()), end(_Sources.end()); it != end; ++it)
{
if ((*it)->getType() == CSourceCommon::SOURCE_SIMPLE)
++count;
}
return count;
}
// ******************************************************************
uint CAudioMixerUser::getAvailableTracksCount() const

View file

@ -48,6 +48,7 @@ CSourceMusicChannel::CSourceMusicChannel() : m_Source(NULL), m_Gain(1.0f)
CSourceMusicChannel::~CSourceMusicChannel()
{
nlassert(!m_Source);
delete m_Source;
m_Source = NULL;
}