diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-09-07 01:02:26 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-09-07 01:02:26 +0400 |
commit | 813d09cb5904bd435a6eefa328314d3cb9076be8 (patch) | |
tree | fb483a45a72fb995bdf57e9173aa7ce09ace5a22 /source | |
parent | 53671577a4ead5e96889a5fcd5a04255f8c948de (diff) |
BGE fix: ignore sounds that cannot be opened instead of crashing. ;-)
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Converter/KX_ConvertActuators.cpp | 21 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_SoundActuator.cpp | 10 |
2 files changed, 23 insertions, 8 deletions
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 8fc224fba6f..6ba178cbb2f 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -413,14 +413,21 @@ void BL_ConvertActuators(char* maggiename, // if sound shall be 3D but isn't mono, we have to make it mono! if(is3d) { - AUD_Reference<AUD_IReader> reader = snd_sound->createReader(); - if(reader->getSpecs().channels != AUD_CHANNELS_MONO) + try { - AUD_DeviceSpecs specs; - specs.channels = AUD_CHANNELS_MONO; - specs.rate = AUD_RATE_INVALID; - specs.format = AUD_FORMAT_INVALID; - snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs); + AUD_Reference<AUD_IReader> reader = snd_sound->createReader(); + if(reader->getSpecs().channels != AUD_CHANNELS_MONO) + { + AUD_DeviceSpecs specs; + specs.channels = AUD_CHANNELS_MONO; + specs.rate = AUD_RATE_INVALID; + specs.format = AUD_FORMAT_INVALID; + snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs); + } + } + catch(AUD_Exception&) + { + // sound cannot be played... ignore } } } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 6c7b515c095..f24243fcdfc 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -108,7 +108,15 @@ void KX_SoundActuator::play() break; } - m_handle = AUD_getDevice()->play(sound, 0); + try + { + m_handle = AUD_getDevice()->play(sound, 0); + } + catch(AUD_Exception&) + { + // cannot play back, ignore + return; + } AUD_Reference<AUD_I3DHandle> handle3d = AUD_Reference<AUD_I3DHandle>(m_handle); |