--- configure +++ configure @@ -158,8 +158,8 @@ ## set up other config.mak variables ###################################################################### GL_LIBS="-lglpng -lGL -lGLU -lm -lz" -AL_LIBS="-L../support/openal/lib -lopenal -ldl" -AL_CFLAGS="-I../support/openal/linux/include -I../support/openal/include" +AL_LIBS="-lopenal -lalut" +AL_CFLAGS="" ## write out config.mak ###################################################################### --- scripts/Makefile.all +++ scripts/Makefile.all @@ -1,5 +1,4 @@ SUPPORT_DIRS = \ - ./support/openal/ \ ./support/glpng/src CHROMIUM_DIRS = \ --- scripts/Makefile.no-setup +++ scripts/Makefile.no-setup @@ -1,5 +1,4 @@ SUPPORT_DIRS = \ - ./support/openal/ \ ./support/glpng/src CHROMIUM_DIRS = \ --- src/AudioOpenAL.cpp +++ src/AudioOpenAL.cpp @@ -43,8 +43,7 @@ //try to use OpenAL alc[GS]etAudioChannel extensions in linux... #ifdef __linux__ #define CD_VOLUME 1 -// #include - #include + #include #endif //__linux__ #endif //USE_SDL #else @@ -52,8 +51,7 @@ //try to use OpenAL alc[GS]etAudioChannel extensions in linux... #ifdef __linux__ #define CD_VOLUME 1 -// #include - #include + #include #endif //__linux__ #endif //USE_SDL #endif @@ -124,6 +122,7 @@ audioScale[0] = 0.5; audioScale[1] = 0.3; audioScale[2] = 0.3; + alDistanceModel(AL_NONE); } if(config->swapStereo()) @@ -235,6 +234,7 @@ printExtensions(stderr, (const char*)alGetString( AL_EXTENSIONS )); fprintf(stderr, "------------------------------------------------------------\n"); + alutInitWithoutContext(NULL, NULL); checkForExtensions(); alListenerfv(AL_POSITION, pos); @@ -310,7 +310,7 @@ //-- check AttenuationScale extension alAttenuationScale = (void (*)(ALfloat param)) - alGetProcAddress((ALubyte *)"alAttenuationScale_LOKI"); + alGetProcAddress("alAttenuationScale_LOKI"); if(alAttenuationScale == NULL) fprintf(stderr, "ATTENTION!! Could not load alAttenuationScale\n"); else @@ -318,9 +318,9 @@ //-- check Audio Channel extension alcGetAudioChannel = (float (*)(ALuint channel)) - alGetProcAddress((const ALubyte *)"alcGetAudioChannel_LOKI"); + alGetProcAddress("alcGetAudioChannel_LOKI"); alcSetAudioChannel = (void (*)(ALuint channel, ALfloat volume)) - alGetProcAddress((const ALubyte *)"alcSetAudioChannel_LOKI"); + alGetProcAddress("alcSetAudioChannel_LOKI"); #ifdef CD_VOLUME if(alcGetAudioChannel) origCDvolume = alcGetAudioChannel(ALC_CHAN_CD_LOKI); @@ -328,10 +328,10 @@ //-- check MP3 extension alutLoadMP3 = (ALboolean (*)(ALuint, ALvoid *, ALint)) - alGetProcAddress((const ALubyte *)"alutLoadMP3_LOKI"); + alGetProcAddress("alutLoadMP3_LOKI"); //-- check Ogg/Vorbis extension alutLoadVorbis = (ALboolean (*)(ALuint, ALvoid *, ALint)) - alGetProcAddress((const ALubyte *)"alutLoadVorbis_LOKI"); + alGetProcAddress("alutLoadVorbis_LOKI"); #endif //_WIN32 } @@ -468,9 +468,6 @@ void AudioOpenAL::loadSounds() { int i; - ALsizei size, freq, bits; - ALenum format; - ALvoid *data; for(i = 0; i < NumSoundTypes; i++) { @@ -481,9 +478,7 @@ else { #ifndef _WIN32 - alutLoadWAV(dataLoc(fileNames[i]), &data, &format, &size, &bits, &freq); - alBufferData (buffer[i], format, data, size, freq); - free(data); + buffer[i] = alutCreateBufferFromFile(dataLoc(fileNames[i])); #else //_WIN32 char nameBuffer[256]; sprintf(nameBuffer, "%s", dataLoc(fileNames[i])); @@ -842,17 +837,8 @@ fprintf(stderr, " PlayList support not compiled into Chromium (AudioOpenAL.cpp)\n"); return false; #else //USE_PLAYLIST - bool retVal; - ALsizei size, freq, bits; - ALenum format; - ALvoid *data; - retVal = alutLoadWAV(filename, &data, &format, &size, &bits, &freq); - if(retVal) - { - alBufferData (buffer[MusicGame], format, data, size, freq); - free(data); - } - return retVal; + buffer[MusicGame] = alutCreateBufferFromFile(filename); + return true; #endif//USE_PLAYLIST } --- src/AudioOpenAL.h +++ src/AudioOpenAL.h @@ -16,6 +16,7 @@ #include #else //macintosh #include +#include #endif //macintosh /** @@ -89,7 +90,7 @@ float origCDvolume; - void *context_id; + ALCcontext *context_id; bool initialized; float audioScale[3]; --- src-setup/Audio.cpp +++ src-setup/Audio.cpp @@ -56,7 +56,7 @@ { fprintf(stderr, "stopping OpenAL..."); if(initialized) - alcDestroyContext(context_id); + alutExit(); initialized = false; fprintf(stderr, "done.\n"); } @@ -71,8 +71,7 @@ if(!initialized) { fprintf(stderr, "starting OpenAL..."); - context_id = alcCreateContext(NULL); - initialized = (bool)context_id; + initialized = alutInit(NULL, NULL); fprintf(stderr, "done.\n"); if(initialized) @@ -81,21 +80,21 @@ #ifndef _WIN32 alAttenuationScale = (void (*)(ALfloat param)) - alGetProcAddress((const ALubyte *)"alAttenuationScale_LOKI"); + alGetProcAddress("alAttenuationScale_LOKI"); if(alAttenuationScale == NULL) fprintf(stderr, "alAttenuationScale NOT present\n"); else alAttenuationScale(1.0); alutLoadMP3 = (ALboolean (*)(ALuint, ALvoid *, ALint)) - alGetProcAddress((const ALubyte *)"alutLoadMP3_LOKI"); + alGetProcAddress("alutLoadMP3_LOKI"); if(alutLoadMP3) fprintf(stderr, "alutLoadMP3_LOKI present\n"); else fprintf(stderr, "alutLoadMP3_LOKI NOT present\n"); alutLoadVorbis = (ALboolean (*)(ALuint, ALvoid *, ALint)) - alGetProcAddress((const ALubyte *)"alutLoadVorbis_LOKI"); + alGetProcAddress("alutLoadVorbis_LOKI"); if(alutLoadVorbis) fprintf(stderr, "alutLoadVorbis_LOKI present\n"); else @@ -271,12 +270,8 @@ //---------------------------------------------------------- bool Audio::loadWAV(const char *filename) { - bool retVal = false; if(initialized) { - ALsizei size, freq, bits; - ALenum format; - ALvoid *data; struct stat sbuf; if(stat(filename, &sbuf) == -1) @@ -286,19 +281,16 @@ return false; } - retVal = alutLoadWAV(filename, &data, &format, &size, &bits, &freq); - if(retVal) - { - alBufferData (buffer[MusicGame], format, data, size, freq); - free(data); - } - else + alGetError(); + buffer[MusicGame] = alutCreateBufferFromFile(filename); + if (buffer[MusicGame] == AL_NONE) { - sprintf(errorBuffer, "ERROR: alutLoadWAV failed for\n\"%s\"\nin Audio::loadWAV", filename); + sprintf(errorBuffer, "ERROR: failed to load\n\"%s\"\nin Audio::loadWAV", filename); fprintf(stderr, "%s\n", errorBuffer); + return false; } } - return retVal; + return true; } //---------------------------------------------------------- --- src-setup/Audio.h +++ src-setup/Audio.h @@ -46,7 +46,6 @@ ALuint buffer[NumSoundTypes]; ALuint source[NumSoundTypes]; - void *context_id; bool initialized; char errorBuffer[512];