X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fsound%2Fsample_openal.cxx;h=c182e829c041bc135e53ec970c3b0b12d8ea59ab;hb=65a880e9fa4b3d9ef7e7e9b234237ff58198ecfd;hp=eaa5452afc7f5a73d4e5e6c9e0c84e9ba28fdf53;hpb=f6314d3124633a05ce249ece5fef6d4f7a07cb76;p=simgear.git diff --git a/simgear/sound/sample_openal.cxx b/simgear/sound/sample_openal.cxx index eaa5452a..c182e829 100644 --- a/simgear/sound/sample_openal.cxx +++ b/simgear/sound/sample_openal.cxx @@ -103,19 +103,33 @@ SGSoundSample::SGSoundSample( const char *path, const char *file, } // Load the sample file -#if defined (__APPLE__) +#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1 + + 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: "+string(alutGetErrorString (error))); + } + +#else + // + // pre 1.0 alut version + // +# if defined (__APPLE__) alutLoadWAVFile( (ALbyte *)samplepath.c_str(), &format, &data, &size, &freq ); -#else +# else alutLoadWAVFile( (ALbyte *)samplepath.c_str(), &format, &data, &size, &freq, &loop ); -#endif +# endif if ( print_openal_error("constructor (alutLoadWAVFile)") ) { throw sg_exception("Failed to load wav file."); } // Copy data to the internal OpenAL buffer alBufferData( buffer, format, data, size, freq ); + if ( print_openal_error("constructor (alBufferData)") ) { throw sg_exception("Failed to buffer data."); } @@ -124,6 +138,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file, alutUnloadWAV( format, data, size, freq ); data = NULL; } +#endif print_openal_error("constructor return"); }