From b3260314ac1ef5a271979226750db3ea87881216 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Apr 2012 23:30:35 +0200 Subject: [PATCH] Fixed: Crash on exit caused by incomplete music channel reset --- code/nel/include/nel/sound/audio_mixer_user.h | 2 ++ code/nel/src/sound/audio_mixer_user.cpp | 30 ++++++++++++++++++- code/nel/src/sound/source_music_channel.cpp | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index 1316fe34a..9c9fd5c86 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -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 diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 8bec4442c..1a6c2d322 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -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 diff --git a/code/nel/src/sound/source_music_channel.cpp b/code/nel/src/sound/source_music_channel.cpp index 677370dd3..34735f113 100644 --- a/code/nel/src/sound/source_music_channel.cpp +++ b/code/nel/src/sound/source_music_channel.cpp @@ -48,6 +48,7 @@ CSourceMusicChannel::CSourceMusicChannel() : m_Source(NULL), m_Gain(1.0f) CSourceMusicChannel::~CSourceMusicChannel() { + nlassert(!m_Source); delete m_Source; m_Source = NULL; }