From 616faf1c516844c1988058694c79a108f6703078 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 12 Apr 2012 21:38:28 +0200 Subject: [PATCH] Fixed: #1298 Replace assert with warning when physical sound source fails to play --- code/nel/src/sound/simple_source.cpp | 8 ++++++++ code/nel/src/sound/stream_source.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/code/nel/src/sound/simple_source.cpp b/code/nel/src/sound/simple_source.cpp index 7c76533e3..cce62cffd 100644 --- a/code/nel/src/sound/simple_source.cpp +++ b/code/nel/src/sound/simple_source.cpp @@ -134,6 +134,7 @@ void CSimpleSource::play() || (_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > _SimpleSound->getMaxDistance() * _SimpleSound->getMaxDistance()) { // The sample buffer is not available, don't play (we don't know the length) + _WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != 0) @@ -175,7 +176,14 @@ void CSimpleSource::play() // and play the sound bool play = pSource->play(); + +#ifdef NL_DEBUG nlassert(play); +#else + if (!play) + nlwarning("Failed to play physical sound source. This is a serious error"); +#endif + // nldebug("CSimpleSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this); } else diff --git a/code/nel/src/sound/stream_source.cpp b/code/nel/src/sound/stream_source.cpp index 1397e87ac..221b0529e 100644 --- a/code/nel/src/sound/stream_source.cpp +++ b/code/nel/src/sound/stream_source.cpp @@ -156,6 +156,7 @@ void CStreamSource::play() if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance()) { // Source is too far to play + m_WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != NULL) @@ -165,7 +166,6 @@ void CStreamSource::play() #ifdef NLSOUND_DEBUG_STREAM nldebug("CStreamSource %p : play FAILED, source is too far away !", (CAudioMixerUser::IMixerEvent*)this); #endif - // m_WaitingForPlay = false; // not necessary, delete ensures waiting for thread stop return; } @@ -221,13 +221,13 @@ void CStreamSource::play() else { // No source available, kill. + m_WaitingForPlay = false; if (_Spawn) { if (_SpawnEndCb != NULL) _SpawnEndCb(this, _CbUserParam); delete this; } - m_WaitingForPlay = false; return; } } @@ -269,6 +269,9 @@ void CStreamSource::play() #ifdef NL_DEBUG nlassert(play); +#else + if (!play) + nlwarning("Failed to play physical sound source. This is a serious error"); #endif }