From 70faa252e7d27e8b8eaa085dc6759881b7d71836 Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 25 Oct 2005 13:06:25 +0000 Subject: [PATCH] Prepare for ALUT version 1.0 --- simgear/sound/openal_test1.cxx | 15 ++++++++++++--- simgear/sound/sample_openal.cxx | 20 +++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/simgear/sound/openal_test1.cxx b/simgear/sound/openal_test1.cxx index e94391e3..25d551ad 100644 --- a/simgear/sound/openal_test1.cxx +++ b/simgear/sound/openal_test1.cxx @@ -115,11 +115,19 @@ int main( int argc, char *argv[] ) { } // Load the sample file -#if defined (__APPLE__) - alutLoadWAVFile( (ALbyte *)"jet.wav", &format, &data, &size, &freq ); +#if defined(ALUT_API_MAJOR_VERSION) && ALUT_API_MAJOR_VERSION >= 1 + + buffer = alutCreateBufferFromFile("jet.wav"); + if (buffer == AL_NONE) { + SG_LOG( SG_GENERAL, SG_ALERT, "Failed to buffer data."); + } + #else +# if defined (__APPLE__) + alutLoadWAVFile( (ALbyte *)"jet.wav", &format, &data, &size, &freq ); +# else alutLoadWAVFile( (ALbyte *)"jet.wav", &format, &data, &size, &freq, &loop ); -#endif +# endif if (alGetError() != AL_NO_ERROR) { SG_LOG( SG_GENERAL, SG_ALERT, "Failed to load wav file."); } @@ -131,6 +139,7 @@ int main( int argc, char *argv[] ) { } alutUnloadWAV( format, data, size, freq ); +#endif alGenSources(1, &source); if (alGetError() != AL_NO_ERROR) { diff --git a/simgear/sound/sample_openal.cxx b/simgear/sound/sample_openal.cxx index eaa5452a..c616bdc8 100644 --- a/simgear/sound/sample_openal.cxx +++ b/simgear/sound/sample_openal.cxx @@ -103,19 +103,32 @@ 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) { + print_openal_error("constructor (alutCreateBufferFromFile)"); + throw sg_exception("Failed to load wav file."); + } + +#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 +137,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file, alutUnloadWAV( format, data, size, freq ); data = NULL; } +#endif print_openal_error("constructor return"); } -- 2.39.5