Removed alut dependency.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1977 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
b04d57330d
commit
1a8ec5578f
3
INSTALL
3
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:
|
||||
|
47
configure.ac
47
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 <AL/alut.h>
|
||||
# define MIN_ALUT_VERSION 1
|
||||
int main() {
|
||||
/* if(alutGetMajorVersion()<MIN_ALUT_VERSION) return -1;*/
|
||||
return 0; }
|
||||
|
||||
],
|
||||
alut_version_ok=yes
|
||||
[ AC_MSG_RESULT(yes)],
|
||||
AC_MSG_FAILURE(too old alut version - using plib instead),
|
||||
alut_version_ok=yes
|
||||
[ AC_MSG_RESULT(yes)])
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl search for the libraries needed to use ogg vorbis
|
||||
AC_SEARCH_LIBS(ov_open, vorbisfile, have_vorbisfile_lib=yes)
|
||||
|
||||
@ -213,15 +182,7 @@ case "${host}" in
|
||||
SUMMARY="$SUMMARY You DO NOT have OpenAL."
|
||||
fi
|
||||
|
||||
if test x$have_alut_hdr = xyes; then
|
||||
if test x$alut_version_ok != xyes; then
|
||||
SUMMARY="$SUMMARY You need to update freealut."
|
||||
fi
|
||||
else
|
||||
SUMMARY="$SUMMARY You DO NOT have freealut."
|
||||
fi
|
||||
|
||||
if test x$have_al_hdr = xyes -a x$alut_version_ok = xyes; then
|
||||
if test x$have_al_hdr = xyes ; then
|
||||
openal_LIBS="$LIBS"
|
||||
AC_DEFINE([HAVE_OPENAL], 1, [Defined when OpenAL is available])
|
||||
SUMMARY="$SUMMARY\nUsing OpenAL for sound."
|
||||
@ -237,7 +198,7 @@ case "${host}" in
|
||||
SUMMARY="$SUMMARY\nPlease install ogg vorbis!"
|
||||
fi
|
||||
else
|
||||
SUMMARY="$SUMMARY\nInstall OpenAL and freealut for music!"
|
||||
SUMMARY="$SUMMARY\nInstall OpenAL for music!"
|
||||
fi
|
||||
|
||||
LIBS=$save_LIBS
|
||||
|
@ -25,7 +25,6 @@
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
#include <AL/alut.h>
|
||||
|
||||
#include "music_ogg.hpp"
|
||||
#include "file_manager.hpp"
|
||||
|
@ -28,7 +28,8 @@
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
#endif
|
||||
#include <AL/alut.h>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,11 @@
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenAL/al.h>
|
||||
# include <OpenAL/alc.h>
|
||||
#else
|
||||
# include <AL/al.h>
|
||||
# include <AL/alc.h>
|
||||
#endif
|
||||
#include <AL/alut.h>
|
||||
|
||||
#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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user