Fixed: #1298 Replace assert with warning when physical sound source fails to play

This commit is contained in:
kaetemi 2012-04-12 21:38:28 +02:00
parent 1317b7aee4
commit e9124dfed6
2 changed files with 13 additions and 2 deletions

View file

@ -134,6 +134,7 @@ void CSimpleSource::play()
|| (_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > _SimpleSound->getMaxDistance() * _SimpleSound->getMaxDistance()) || (_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) // The sample buffer is not available, don't play (we don't know the length)
_WaitingForPlay = false;
if (_Spawn) if (_Spawn)
{ {
if (_SpawnEndCb != 0) if (_SpawnEndCb != 0)
@ -175,7 +176,14 @@ void CSimpleSource::play()
// and play the sound // and play the sound
bool play = pSource->play(); bool play = pSource->play();
#ifdef NL_DEBUG
nlassert(play); 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); // nldebug("CSimpleSource %p : REAL play done", (CAudioMixerUser::IMixerEvent*)this);
} }
else else

View file

@ -156,6 +156,7 @@ void CStreamSource::play()
if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance()) if ((_RelativeMode ? getPos().sqrnorm() : (mixer->getListenPosVector() - getPos()).sqrnorm()) > m_StreamSound->getMaxDistance() * m_StreamSound->getMaxDistance())
{ {
// Source is too far to play // Source is too far to play
m_WaitingForPlay = false;
if (_Spawn) if (_Spawn)
{ {
if (_SpawnEndCb != NULL) if (_SpawnEndCb != NULL)
@ -165,7 +166,6 @@ void CStreamSource::play()
#ifdef NLSOUND_DEBUG_STREAM #ifdef NLSOUND_DEBUG_STREAM
nldebug("CStreamSource %p : play FAILED, source is too far away !", (CAudioMixerUser::IMixerEvent*)this); nldebug("CStreamSource %p : play FAILED, source is too far away !", (CAudioMixerUser::IMixerEvent*)this);
#endif #endif
// m_WaitingForPlay = false; // not necessary, delete ensures waiting for thread stop
return; return;
} }
@ -221,13 +221,13 @@ void CStreamSource::play()
else else
{ {
// No source available, kill. // No source available, kill.
m_WaitingForPlay = false;
if (_Spawn) if (_Spawn)
{ {
if (_SpawnEndCb != NULL) if (_SpawnEndCb != NULL)
_SpawnEndCb(this, _CbUserParam); _SpawnEndCb(this, _CbUserParam);
delete this; delete this;
} }
m_WaitingForPlay = false;
return; return;
} }
} }
@ -269,6 +269,9 @@ void CStreamSource::play()
#ifdef NL_DEBUG #ifdef NL_DEBUG
nlassert(play); nlassert(play);
#else
if (!play)
nlwarning("Failed to play physical sound source. This is a serious error");
#endif #endif
} }