From: Matthias Braun Date: Sun, 10 Sep 2006 09:49:06 +0000 (+0000) Subject: catch exceptions when we can't create new audio sources X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2cf6395a34d40211c80da918f7f7376126d3ebe8;p=supertux.git catch exceptions when we can't create new audio sources SVN-Revision: 4221 --- diff --git a/src/audio/sound_manager.cpp b/src/audio/sound_manager.cpp index cc9dc40ea..732ebf62e 100644 --- a/src/audio/sound_manager.cpp +++ b/src/audio/sound_manager.cpp @@ -117,6 +117,14 @@ SoundManager::create_sound_source(const std::string& filename) if(!sound_enabled) return create_dummy_sound_source(); + std::auto_ptr source; + try { + source.reset(new OpenALSoundSource()); + } catch(std::exception& e) { + log_warning << "Couldn't create audio source: " << e.what() << std::endl; + return create_dummy_sound_source(); + } + ALuint buffer; // reuse an existing static sound buffer @@ -142,9 +150,8 @@ SoundManager::create_sound_source(const std::string& filename) } } - OpenALSoundSource* source = new OpenALSoundSource(); alSourcei(source->source, AL_BUFFER, buffer); - return source; + return source.release(); } void