X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2Fopenal_wrapper.cpp;h=b6292ab3233b56993c6e6ca8ee6358c477497ffa;hb=fe831b45a76f058d17bfef8b5f45d7e563d97089;hp=488a371c0f160df7b9e0ed93584df87a6dc18678;hpb=256029f43f2892983287b8e5f06720e754a4000f;p=lugaru.git diff --git a/Source/openal_wrapper.cpp b/Source/openal_wrapper.cpp index 488a371..b6292ab 100644 --- a/Source/openal_wrapper.cpp +++ b/Source/openal_wrapper.cpp @@ -1,3 +1,24 @@ +/* +Copyright (C) 2003, 2010 - Wolfire Games + +This file is part of Lugaru. + +Lugaru is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + #if USE_OPENAL @@ -5,6 +26,10 @@ #include #include +#ifdef _MSC_VER +#include +#endif + #include "MacCompatibility.h" #include "fmod.h" @@ -184,15 +209,15 @@ void F_API OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, signed char F_API OPENAL_3D_SetAttributes(int channel, const float *pos, const float *vel) { - if (!initialized) return FALSE; - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if (!initialized) return false; + if ((channel < 0) || (channel >= num_channels)) return false; if (pos != NULL) set_channel_position(channel, pos[0], pos[1], -pos[2]); // we ignore velocity, since doppler's broken in the Linux AL at the moment... - return TRUE; + return true; } void F_API OPENAL_3D_SetDopplerFactor(float scale) @@ -203,31 +228,31 @@ void F_API OPENAL_3D_SetDopplerFactor(float scale) signed char F_API OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int flags) { - if (initialized) return FALSE; - if (maxsoftwarechannels == 0) return FALSE; + if (initialized) return false; + if (maxsoftwarechannels == 0) return false; if (flags != 0) // unsupported. - return FALSE; + return false; if (!lookup_all_alsyms("./openal.so")) // !!! FIXME: linux specific lib name { if (!lookup_all_alsyms("openal.so.1")) // !!! FIXME: linux specific lib name { if (!lookup_all_alsyms("openal.so")) // !!! FIXME: linux specific lib name - return FALSE; + return false; } } ALCdevice *dev = alcOpenDevice(NULL); if (!dev) - return FALSE; + return false; ALint caps[] = { ALC_FREQUENCY, mixrate, 0 }; ALCcontext *ctx = alcCreateContext(dev, caps); if (!ctx) { alcCloseDevice(dev); - return FALSE; + return false; } alcMakeContextCurrent(ctx); @@ -249,7 +274,7 @@ signed char F_API OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned int alGenSources(1, &channels[i].sid); // !!! FIXME: verify this didn't fail! initialized = true; - return TRUE; + return true; } void F_API OPENAL_Close() @@ -289,14 +314,14 @@ FSOUND_SAMPLE *F_API OPENAL_GetCurrentSample(int channel) signed char F_API OPENAL_GetPaused(int channel) { - if (!initialized) return FALSE; - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if (!initialized) return false; + if ((channel < 0) || (channel >= num_channels)) return false; if (channels[channel].startpaused) - return(TRUE); + return(true); ALint state = 0; alGetSourceiv(channels[channel].sid, AL_SOURCE_STATE, &state); - return((state == AL_PAUSED) ? TRUE : FALSE); + return((state == AL_PAUSED) ? true : false); } unsigned int F_API OPENAL_GetLoopMode(int channel) @@ -312,11 +337,11 @@ unsigned int F_API OPENAL_GetLoopMode(int channel) signed char F_API OPENAL_IsPlaying(int channel) { - if (!initialized) return FALSE; - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if (!initialized) return false; + if ((channel < 0) || (channel >= num_channels)) return false; ALint state = 0; alGetSourceiv(channels[channel].sid, AL_SOURCE_STATE, &state); - return((state == AL_PLAYING) ? TRUE : FALSE); + return((state == AL_PLAYING) ? true : false); } int F_API OPENAL_PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused) @@ -504,17 +529,17 @@ void F_API OPENAL_Sample_Free(FSOUND_SAMPLE *sptr) signed char F_API OPENAL_Sample_SetMode(FSOUND_SAMPLE *sptr, unsigned int mode) { - if (!initialized) return FALSE; - if ((mode != FSOUND_LOOP_NORMAL) && (mode != FSOUND_LOOP_OFF)) return FALSE; - if (!sptr) return FALSE; + if (!initialized) return false; + if ((mode != FSOUND_LOOP_NORMAL) && (mode != FSOUND_LOOP_OFF)) return false; + if (!sptr) return false; sptr->mode = mode; - return TRUE; + return true; } signed char F_API OPENAL_Sample_SetMinMaxDistance(FSOUND_SAMPLE *sptr, float mindist, float maxdist) { - if (!initialized) return FALSE; - if (sptr == NULL) return FALSE; + if (!initialized) return false; + if (sptr == NULL) return false; sptr->min_distance = mindist; // we ignore maxdist. It's not really important to this game, and the // FMOD docs suggest that it's worthless anyhow. @@ -534,54 +559,54 @@ signed char F_API OPENAL_Sample_SetMinMaxDistance(FSOUND_SAMPLE *sptr, float min signed char F_API OPENAL_SetFrequency(int channel, int freq) { - if (!initialized) return FALSE; + if (!initialized) return false; if (channel == FSOUND_ALL) { for (int i = 0; i < num_channels; i++) OPENAL_SetFrequency(i, freq); - return TRUE; + return true; } - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if ((channel < 0) || (channel >= num_channels)) return false; if (freq == 8012) // hack alSourcef(channels[channel].sid, AL_PITCH, 8012.0f / 44100.0f); else alSourcef(channels[channel].sid, AL_PITCH, 1.0f); - return TRUE; + return true; } signed char F_API OPENAL_SetVolume(int channel, int vol) { - if (!initialized) return FALSE; + if (!initialized) return false; if (channel == FSOUND_ALL) { for (int i = 0; i < num_channels; i++) OPENAL_SetVolume(i, vol); - return TRUE; + return true; } - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if ((channel < 0) || (channel >= num_channels)) return false; if (vol < 0) vol = 0; else if (vol > 255) vol = 255; ALfloat gain = ((ALfloat) vol) / 255.0f; alSourcef(channels[channel].sid, AL_GAIN, gain); - return TRUE; + return true; } signed char F_API OPENAL_SetPaused(int channel, signed char paused) { - if (!initialized) return FALSE; + if (!initialized) return false; if (channel == FSOUND_ALL) { for (int i = 0; i < num_channels; i++) OPENAL_SetPaused(i, paused); - return TRUE; + return true; } - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if ((channel < 0) || (channel >= num_channels)) return false; ALint state = 0; if (channels[channel].startpaused) @@ -596,7 +621,7 @@ signed char F_API OPENAL_SetPaused(int channel, signed char paused) alSourcePlay(channels[channel].sid); channels[channel].startpaused = false; } - return TRUE; + return true; } void F_API OPENAL_SetSFXMasterVolume(int volume) @@ -608,19 +633,19 @@ void F_API OPENAL_SetSFXMasterVolume(int volume) signed char F_API OPENAL_StopSound(int channel) { - if (!initialized) return FALSE; + if (!initialized) return false; if (channel == FSOUND_ALL) { for (int i = 0; i < num_channels; i++) OPENAL_StopSound(i); - return TRUE; + return true; } - if ((channel < 0) || (channel >= num_channels)) return FALSE; + if ((channel < 0) || (channel >= num_channels)) return false; alSourceStop(channels[channel].sid); channels[channel].startpaused = false; - return TRUE; + return true; } FSOUND_STREAM * F_API OPENAL_Stream_Open(const char *name_or_data, unsigned int mode, int offset, int length) @@ -646,7 +671,7 @@ int F_API OPENAL_Stream_PlayEx(int channel, FSOUND_STREAM *stream, FSOUND_DSPUNI signed char F_API OPENAL_Stream_Stop(FSOUND_STREAM *stream) { - if (!initialized) return FALSE; + if (!initialized) return false; for (int i = 0; i < num_channels; i++) { if (channels[i].sample == (FSOUND_SAMPLE *) stream) @@ -655,7 +680,7 @@ signed char F_API OPENAL_Stream_Stop(FSOUND_STREAM *stream) channels[i].startpaused = false; } } - return TRUE; + return true; } signed char F_API OPENAL_Stream_SetMode(FSOUND_STREAM *stream, unsigned int mode) @@ -671,7 +696,7 @@ void F_API OPENAL_Update() signed char F_API OPENAL_SetOutput(int outputtype) { - return TRUE; + return true; } #endif