Here is the patch if you want to apply it yourself:
Code:
diff -u -r -x .svn ./freeorion/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp ./freeorion-devel/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp
--- ./freeorion/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp 2008-01-22 13:47:10.000000000 +0100
+++ ./freeorion-devel/FreeOrion/client/human/HumanClientAppSoundOpenAL.cpp 2008-02-08 14:44:55.000000000 +0100
@@ -12,31 +12,63 @@
{
ALCcontext *m_context;
ALCdevice *m_device;
-
+ ALenum error_code;
+
m_device = alcOpenDevice(NULL); /* currently only select the default output device - usually a NULL-terminated
* string desctribing a device can be passed here (of type ALchar*)
*/
- if (m_device == NULL) {
+ if (m_device == NULL)
Logger().errorStream() << "Unable to initialise OpenAL device: " << alGetString(alGetError()) << "\n";
- } else {
+ else
+ {
m_context = alcCreateContext(m_device,NULL); // instead of NULL we can pass a ALCint* pointing to a set of
- alcMakeContextCurrent(m_context); // attributes (ALC_FREQUENCY, ALC_REFRESH and ALC_SYNC)
- alutInitWithoutContext(NULL,NULL); // we need to init alut or we won't be able to read .wav files
- alListenerf(AL_GAIN,1.0);
- alGenSources(num_sources, sources);
- alGenBuffers(2, music_buffers);
- for (int i = 0; i < num_sources; ++i) {
- alSourcei(sources[i], AL_SOURCE_RELATIVE, AL_TRUE);
+ // attributes (ALC_FREQUENCY, ALC_REFRESH and ALC_SYNC)
+
+ if ((m_context != NULL) && (alcMakeContextCurrent(m_context) == AL_TRUE))
+ {
+ alutInitWithoutContext(NULL,NULL); // we need to init alut or we won't be able to read .wav files
+ alListenerf(AL_GAIN,1.0);
+ alGetError(); // clear possible previous errors (just to be certain)
+ alGenSources(num_sources, sources);
+ error_code = alGetError();
+ if(error_code != AL_NO_ERROR)
+ {
+ Logger().errorStream() << "Unable to create OpenAL sources: " << alGetString(error_code) << "\n" << "Disabling OpenAL sound system!\n";
+ alcMakeContextCurrent(NULL);
+ alcDestroyContext(m_context);
+ }
+ else
+ {
+ alGetError();
+ alGenBuffers(2, music_buffers);
+ error_code = alGetError();
+ if(error_code != AL_NO_ERROR)
+ {
+ Logger().errorStream() << "Unable to create OpenAL buffers: " << alGetString(error_code) << "\n" << "Disabling OpenAL sound system!\n";
+ alDeleteBuffers(2, music_buffers);
+ alcMakeContextCurrent(NULL);
+ alcDestroyContext(m_context);
+ }
+ else
+ {
+ for (int i = 0; i < num_sources; ++i)
+ {
+ alSourcei(sources[i], AL_SOURCE_RELATIVE, AL_TRUE);
+ }
+ Logger().debugStream() << "OpenAL initialized. Version "
+ << alGetString(AL_VERSION)
+ << "Renderer "
+ << alGetString(AL_RENDERER)
+ << "Vendor "
+ << alGetString(AL_VENDOR)
+ << "\nExtensions: "
+ << alGetString(AL_EXTENSIONS)
+ << "\n";
+ }
+ }
}
- Logger().debugStream() << "OpenAL initialized. Version "
- << alGetString(AL_VERSION)
- << "Renderer "
- << alGetString(AL_RENDERER)
- << "Vendor "
- << alGetString(AL_VENDOR)
- << "\nExtensions: "
- << alGetString(AL_EXTENSIONS)
- << "\n";
+ else
+ Logger().errorStream() << "Unable to create OpenAL context : " << alGetString(alGetError()) << "\n";
}
}
This is a quick fix (Disables the whole system if can't get the required number of buffers/sources as those numbers are currently hard-coded in all sound-related functions. I'll make a more elegant solution (try to use smaller amount of sources, then disable sound if that fails) later - currently too exhausted and sleep-deprieved (blame the university I'm attending))