diff --git a/INSTALL b/INSTALL index 00fc3929f..895a551d5 100755 --- a/INSTALL +++ b/INSTALL @@ -10,7 +10,6 @@ First, make sure that you have the following packages installed: * PLIB version 1.8.4 or later * SDL 1.2 or later * OpenAL - * freealut Unpack the files from the tarball like this: @@ -43,7 +42,7 @@ Here are the compilation instructions for the current svn(05 oct. 2006) of Super Tux Kart on Ubuntu Edgy, contributed by Damien: install following packages: -# apt-get install libopenal-dev libalut-dev libmikmod2-dev plib1.8.4-dev +# apt-get install libopenal-dev libmikmod2-dev plib1.8.4-dev libglu1-mesa-dev subversion autoconf automake1.9 g++ gcc do a: diff --git a/configure.ac b/configure.ac index 04e98165e..f2d7e1e3c 100644 --- a/configure.ac +++ b/configure.ac @@ -94,10 +94,6 @@ dnl Add special compiler flags for certain platforms dnl ================================================ case "${host}" in *darwin*|*macosx*) - AC_CHECK_PROGS(have_pkg_config,[pkg-config],"no") - if test x$have_pkg_config != xno; then - LDFLAGS="$LDFLAGS `pkg-config --libs freealut`" - fi LDFLAGS="$LDFLAGS -lintl" esac @@ -142,14 +138,14 @@ case "${host}" in esac dnl ======================================== -dnl check for OpenAL (al and alut) libraries +dnl check for OpenAL libraries dnl ======================================== dnl FIXME: this all appears too complicated, doing unnecesary dnl tests etc --> needs cleanup dnl The check for OpenAL headers depends on the OS, since dnl Apple has the headers in OpenAL/al.h instead of AL/al.h -AC_SEARCH_LIBS(alGenBuffers, [openal alut], have_al_lib=yes) +AC_SEARCH_LIBS(alGenBuffers, [openal], have_al_lib=yes) dnl We also check for ogg vorbis support now. dnl we have 4 sound libraries to check, first we check for OpenAL @@ -171,33 +167,6 @@ case "${host}" in dnl check for libraries save_LIBS=$LIBS - dnl AL/al.h is checked before, since Macs need a different path - - dnl check for freealut - AC_SEARCH_LIBS(alutInit, alut, have_alut_lib=yes) - if test x$have_alut_lib = xyes; then - AC_CHECK_HEADER(AL/alut.h, have_alut_hdr=yes) - - if test x$have_alut_hdr = xyes; then - AC_MSG_CHECKING([for alut version 1.0.0 or later ]) - - dnl check for right version of alut, must be at least 1.0 - AC_RUN_IFELSE([ -# include -# define MIN_ALUT_VERSION 1 - int main() { -/* if(alutGetMajorVersion() #endif -#include #include "music_ogg.hpp" #include "file_manager.hpp" diff --git a/src/sfx_openal.cpp b/src/sfx_openal.cpp index 11e42982c..a2259d33d 100644 --- a/src/sfx_openal.cpp +++ b/src/sfx_openal.cpp @@ -28,7 +28,8 @@ #else # include #endif -#include + +#include #include "sfx_openal.hpp" #include "file_manager.hpp" @@ -77,41 +78,45 @@ bool SFXImpl::load(const char* filename) return false; } ALenum format = 0; - ALsizei size = 0, freq = 0; - ALvoid* data = NULL; - ALboolean loop = AL_FALSE; + Uint32 size = 0; + Uint8* data = NULL; + SDL_AudioSpec spec; -#ifdef __APPLE__ - alutLoadWAVFile((ALbyte*)path.c_str(), &format, &data, &size, &freq); -#else - alutLoadWAVFile((ALbyte*)path.c_str(), &format, &data, &size, &freq, &loop); -#endif - - if (data == NULL) + if( SDL_LoadWAV( path.c_str(), &spec, &data, &size ) == NULL) { - const int ALUT_ERROR = alutGetError(); - fprintf(stderr, "Error 1 loading SFX: %s failed because %s \n", path.c_str(), alutGetErrorString(ALUT_ERROR)); + fprintf(stderr, "Error 1 loading SFX: with file %s, SDL_LoadWAV() failed\n", path.c_str()); return false; } - alBufferData(m_soundBuffer, format, data, size, freq); + switch( spec.format ) + { + case AUDIO_U8: + case AUDIO_S8: + if( spec.channels == 2 ) format = AL_FORMAT_STEREO8; + else format = AL_FORMAT_MONO8; + break; + case AUDIO_U16LSB: + case AUDIO_S16LSB: + case AUDIO_U16MSB: + case AUDIO_S16MSB: + if( spec.channels == 2 ) format = AL_FORMAT_STEREO16; + else format = AL_FORMAT_MONO16; + break; + } + + alBufferData(m_soundBuffer, format, data, size, spec.freq); if (alGetError() != AL_NO_ERROR) { fprintf(stderr, "Error 2 loading SFX: %s failed\n", path.c_str()); return false; } - alutUnloadWAV(format, data, size, freq); - if (alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error 3 loading SFX: %s failed\n", path.c_str()); - return false; - } + SDL_FreeWAV(data); alGenSources(1, &m_soundSource ); if (alGetError() != AL_NO_ERROR) { - fprintf(stderr, "Error 4 loading SFX: %s failed\n", path.c_str()); + fprintf(stderr, "Error 3 loading SFX: %s failed\n", path.c_str()); return false; } diff --git a/src/sound_manager.cpp b/src/sound_manager.cpp index ccd6939a7..88f32e17e 100644 --- a/src/sound_manager.cpp +++ b/src/sound_manager.cpp @@ -29,10 +29,11 @@ #ifdef __APPLE__ # include +# include #else # include +# include #endif -#include #include "music_ogg.hpp" #include "sfx_openal.hpp" @@ -46,12 +47,28 @@ SoundManager* sound_manager= NULL; SoundManager::SoundManager() : m_sfxs(NUM_SOUNDS) { m_current_music= NULL; - if(alutInit(0, NULL) == AL_TRUE) // init OpenAL sound system - m_initialized = true; + + ALCdevice* device = alcOpenDevice ( NULL ); //The default sound device + if( device == NULL ) + { + fprintf(stderr, "WARNING: Could open the default sound device.\n"); + m_initialized = false; + } else { - fprintf(stderr, "WARNING: Could not initialize the ALUT based sound.\n"); - m_initialized = false; + + ALCcontext* context = alcCreateContext( device, NULL ); + + if( context == NULL ) + { + fprintf(stderr, "WARNING: Could create a sound context.\n"); + m_initialized = false; + } + else + { + alcMakeContextCurrent( context ); + m_initialized = true; + } } alGetError(); //Called here to clear any non-important errors found @@ -94,7 +111,13 @@ SoundManager::~SoundManager() if(m_initialized) { - alutExit(); + ALCcontext* context = alcGetCurrentContext(); + ALCdevice* device = alcGetContextsDevice( context ); + + alcMakeContextCurrent( NULL ); + alcDestroyContext( context ); + + alcCloseDevice( device ); } } // ~SoundManager