Oops, ALUT 1.0 requires a little more work than expected.

This commit is contained in:
ehofman
2005-10-25 18:05:23 +00:00
parent 37b4005d3e
commit 65a880e9fa
2 changed files with 17 additions and 1 deletions

View File

@@ -107,8 +107,9 @@ SGSoundSample::SGSoundSample( const char *path, const char *file,
buffer = alutCreateBufferFromFile(samplepath.c_str());
if (buffer == AL_NONE) {
ALenum error = alutGetError ();
print_openal_error("constructor (alutCreateBufferFromFile)");
throw sg_exception("Failed to load wav file.");
throw sg_exception("Failed to load wav file: "+string(alutGetErrorString (error)));
}
#else

View File

@@ -80,6 +80,16 @@ SGSoundMgr::SGSoundMgr() {
SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
// initialize OpenAL
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
if (!alutInit(NULL, NULL))
{
ALenum error = alutGetError ();
SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
SG_LOG( SG_GENERAL, SG_ALERT, " "+string(alutGetErrorString(error)));
working = false;
}
context = alcGetCurrentContext();
#else
if ( (dev = alcOpenDevice( NULL )) != NULL
&& ( context = alcCreateContext( dev, NULL )) != NULL ) {
working = true;
@@ -89,6 +99,7 @@ SGSoundMgr::SGSoundMgr() {
context = 0;
SG_LOG( SG_GENERAL, SG_ALERT, "Audio initialization failed!" );
}
#endif
listener_pos[0] = 0.0;
listener_pos[1] = 0.0;
@@ -124,8 +135,12 @@ SGSoundMgr::SGSoundMgr() {
SGSoundMgr::~SGSoundMgr() {
#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1
alutExit ();
#else
if (context)
alcDestroyContext( context );
#endif
//
// Remove the samples from the sample manager.
//