From: curt Date: Thu, 1 Jul 2004 19:05:37 +0000 (+0000) Subject: If we pass in a position or velocity of nan, openal will generate an assertion. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a7b35c6e22125f31c68c35b7436f72c2feef5970;p=simgear.git If we pass in a position or velocity of nan, openal will generate an assertion. Under rare circumstances we could encounter a non-cooperative external fdm that could trigger this condition. This patch catches the problem and returns rather than letting FG get killed. --- diff --git a/simgear/sound/soundmgr_openal.cxx b/simgear/sound/soundmgr_openal.cxx index daf0729e..8bb70480 100644 --- a/simgear/sound/soundmgr_openal.cxx +++ b/simgear/sound/soundmgr_openal.cxx @@ -23,7 +23,7 @@ // // $Id$ -#include +#include #if defined(__APPLE__) # include @@ -35,6 +35,19 @@ # include #endif +#if defined (__APPLE__) +// any C++ header file undefines isinf and isnan +// so this should be included before +inline int (isinf)(double r) { return isinf(r); } +inline int (isnan)(double r) { return isnan(r); } +#endif + +#if defined(__MINGW32__) +#define isnan(x) _isnan(x) +#endif + +#include STL_IOSTREAM + #include #include @@ -275,6 +288,11 @@ bool SGSoundMgr::stop( const string& refname ) { // set source position of all managed sounds void SGSoundMgr::set_source_pos_all( ALfloat *pos ) { + if ( isnan(pos[0]) || isnan(pos[1]) || isnan(pos[2]) ) { + // bail if a bad position is passed in + return; + } + sample_map_iterator sample_current = samples.begin(); sample_map_iterator sample_end = samples.end(); for ( ; sample_current != sample_end; ++sample_current ) { @@ -286,6 +304,11 @@ void SGSoundMgr::set_source_pos_all( ALfloat *pos ) { // set source velocity of all managed sounds void SGSoundMgr::set_source_vel_all( ALfloat *vel ) { + if ( isnan(vel[0]) || isnan(vel[1]) || isnan(vel[2]) ) { + // bail if a bad velocity is passed in + return; + } + sample_map_iterator sample_current = samples.begin(); sample_map_iterator sample_end = samples.end(); for ( ; sample_current != sample_end; ++sample_current ) {