X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FAudio%2Fopenal_wrapper.cpp;h=e8203af75bbf377414a1b59af796ad1f4c949e83;hb=03fbcc5b5e18dbf62c48849fc8d02cd250aa744e;hp=90b49d70c0a654665c0bb1077ba93a3163973ee3;hpb=3a6ebcc050c7ee941e5d5ea243f59827d113d968;p=lugaru.git
diff --git a/Source/Audio/openal_wrapper.cpp b/Source/Audio/openal_wrapper.cpp
index 90b49d7..e8203af 100644
--- a/Source/Audio/openal_wrapper.cpp
+++ b/Source/Audio/openal_wrapper.cpp
@@ -22,7 +22,7 @@ along with Lugaru. If not, see .
#include "Audio/Sounds.hpp"
#include "Game.hpp"
-#include "Math/Quaternions.hpp"
+#include "Math/XYZ.hpp"
#include
#include
@@ -79,7 +79,7 @@ static void set_channel_position(const int channel, const float x,
}
-AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel, float fx, float fy, float fz, float tx, float ty, float tz)
+AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *, float fx, float fy, float fz, float tx, float ty, float tz)
{
if (!initialized)
return;
@@ -90,23 +90,23 @@ AL_API void OPENAL_3D_Listener_SetAttributes(const float *pos, const float *vel,
listener_position[2] = -pos[2];
}
- ALfloat vec[6] = { fx, fy, -fz, tz, ty, -tz };
+ ALfloat vec[6] = { fx, fy, -fz, tx, ty, -tz };
alListenerfv(AL_ORIENTATION, vec);
// we ignore velocity, since doppler's broken in the Linux AL at the moment...
// adjust existing positions...
- for (int i = 0; i < num_channels; i++) {
+ for (unsigned i = 0; i < num_channels; i++) {
const float *p = impl_channels[i].position;
set_channel_position(i, p[0], p[1], p[2]);
}
}
-AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const float *vel)
+AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos)
{
if (!initialized)
return false;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (pos != NULL)
@@ -117,11 +117,11 @@ AL_API signed char OPENAL_3D_SetAttributes(int channel, const float *pos, const
return true;
}
-AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos, const float *vel)
+AL_API signed char OPENAL_3D_SetAttributes_(int channel, const XYZ &pos)
{
if (!initialized)
return false;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
set_channel_position(channel, pos.x, pos.y, -pos.z);
@@ -163,7 +163,7 @@ AL_API signed char OPENAL_Init(int mixrate, int maxsoftwarechannels, unsigned in
num_channels = maxsoftwarechannels;
impl_channels = new OPENAL_Channels[maxsoftwarechannels];
memset(impl_channels, '\0', sizeof (OPENAL_Channels) * num_channels);
- for (int i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++)
alGenSources(1, &impl_channels[i].sid); // !!! FIXME: verify this didn't fail!
initialized = true;
@@ -177,7 +177,7 @@ AL_API void OPENAL_Close()
ALCcontext *ctx = alcGetCurrentContext();
if (ctx) {
- for (int i = 0; i < num_channels; i++) {
+ for (unsigned i = 0; i < num_channels; i++) {
alSourceStop(impl_channels[i].sid);
alSourcei(impl_channels[i].sid, AL_BUFFER, 0);
alDeleteSources(1, &impl_channels[i].sid);
@@ -200,7 +200,7 @@ static OPENAL_SAMPLE *OPENAL_GetCurrentSample(int channel)
{
if (!initialized)
return NULL;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return NULL;
return impl_channels[channel].sample;
}
@@ -209,7 +209,7 @@ static signed char OPENAL_GetPaused(int channel)
{
if (!initialized)
return false;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (impl_channels[channel].startpaused)
return(true);
@@ -223,7 +223,7 @@ static unsigned int OPENAL_GetLoopMode(int channel)
{
if (!initialized)
return 0;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return 0;
ALint loop = 0;
alGetSourceiv(impl_channels[channel].sid, AL_LOOPING, &loop);
@@ -236,7 +236,7 @@ static signed char OPENAL_IsPlaying(int channel)
{
if (!initialized)
return false;
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
ALint state = 0;
alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
@@ -252,7 +252,7 @@ static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *
if (dsp != NULL)
return -1;
if (channel == OPENAL_FREE) {
- for (int i = 0; i < num_channels; i++) {
+ for (unsigned i = 0; i < num_channels; i++) {
ALint state = 0;
alGetSourceiv(impl_channels[i].sid, AL_SOURCE_STATE, &state);
if ((state != AL_PLAYING) && (state != AL_PAUSED)) {
@@ -262,7 +262,7 @@ static int OPENAL_PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *
}
}
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return -1;
alSourceStop(impl_channels[channel].sid);
impl_channels[channel].sample = sptr;
@@ -341,7 +341,7 @@ static void *decode_to_pcm(const char *_fname, ALenum &format, ALsizei &size, AL
while ( (rc = ov_read(&vf, buf, sizeof (buf), bigendian, 2, 1, &bitstream)) != 0 ) {
if (rc > 0) {
size += rc;
- if (size >= allocated) {
+ if (size >= (int)allocated) {
allocated *= 2;
ALubyte *tmp = (ALubyte *) realloc(retval, allocated);
if (tmp == NULL) {
@@ -407,7 +407,7 @@ AL_API void OPENAL_Sample_Free(OPENAL_SAMPLE *sptr)
if (!initialized)
return;
if (sptr) {
- for (int i = 0; i < num_channels; i++) {
+ for (unsigned i = 0; i < num_channels; i++) {
if (impl_channels[i].sample == sptr) {
alSourceStop(impl_channels[i].sid);
alSourcei(impl_channels[i].sid, AL_BUFFER, 0);
@@ -437,12 +437,12 @@ AL_API signed char OPENAL_SetFrequency(int channel, bool slomo)
if (!initialized)
return false;
if (channel == OPENAL_ALL) {
- for (int i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++)
OPENAL_SetFrequency(i, slomo);
return true;
}
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (slomo)
alSourcef(impl_channels[channel].sid, AL_PITCH, ((ALfloat) slomofreq) / 44100.0f);
@@ -457,12 +457,12 @@ AL_API signed char OPENAL_SetVolume(int channel, int vol)
return false;
if (channel == OPENAL_ALL) {
- for (int i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++)
OPENAL_SetVolume(i, vol);
return true;
}
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
if (vol < 0)
@@ -480,12 +480,12 @@ AL_API signed char OPENAL_SetPaused(int channel, signed char paused)
return false;
if (channel == OPENAL_ALL) {
- for (int i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++)
OPENAL_SetPaused(i, paused);
return true;
}
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
ALint state = 0;
@@ -517,12 +517,12 @@ AL_API signed char OPENAL_StopSound(int channel)
return false;
if (channel == OPENAL_ALL) {
- for (int i = 0; i < num_channels; i++)
+ for (unsigned i = 0; i < num_channels; i++)
OPENAL_StopSound(i);
return true;
}
- if ((channel < 0) || (channel >= num_channels))
+ if ((channel < 0) || (channel >= (int)num_channels))
return false;
alSourceStop(impl_channels[channel].sid);
impl_channels[channel].startpaused = false;
@@ -545,7 +545,7 @@ static signed char OPENAL_Stream_Stop(OPENAL_STREAM *stream)
{
if (!initialized)
return false;
- for (int i = 0; i < num_channels; i++) {
+ for (unsigned i = 0; i < num_channels; i++) {
if (impl_channels[i].sample == (OPENAL_SAMPLE *) stream) {
alSourceStop(impl_channels[i].sid);
impl_channels[i].startpaused = false;
@@ -566,11 +566,6 @@ AL_API void OPENAL_Update()
alcProcessContext(alcGetCurrentContext());
}
-AL_API signed char OPENAL_SetOutput(int outputtype)
-{
- return true;
-}
-
extern int channels[];
extern "C" void PlaySoundEx(int chan, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused)