} OPENAL_SAMPLE;
static size_t num_channels = 0;
-static OPENAL_Channels *channels = NULL;
+static OPENAL_Channels *impl_channels = NULL;
static bool initialized = false;
static float listener_position[3];
static void set_channel_position(const int channel, const float x,
const float y, const float z)
{
- OPENAL_Channels *chan = &channels[channel];
+ OPENAL_Channels *chan = &impl_channels[channel];
chan->position[0] = x;
chan->position[1] = y;
// adjust existing positions...
for (int i = 0; i < num_channels; i++)
{
- const float *p = channels[i].position;
+ const float *p = impl_channels[i].position;
set_channel_position(i, p[0], p[1], p[2]);
}
}
}
num_channels = maxsoftwarechannels;
- channels = new OPENAL_Channels[maxsoftwarechannels];
- memset(channels, '\0', sizeof (OPENAL_Channels) * num_channels);
+ impl_channels = new OPENAL_Channels[maxsoftwarechannels];
+ memset(impl_channels, '\0', sizeof (OPENAL_Channels) * num_channels);
for (int i = 0; i < num_channels; i++)
- alGenSources(1, &channels[i].sid); // !!! FIXME: verify this didn't fail!
+ alGenSources(1, &impl_channels[i].sid); // !!! FIXME: verify this didn't fail!
initialized = true;
return true;
{
for (int i = 0; i < num_channels; i++)
{
- alSourceStop(channels[i].sid);
- alSourcei(channels[i].sid, AL_BUFFER, 0);
- alDeleteSources(1, &channels[i].sid);
+ alSourceStop(impl_channels[i].sid);
+ alSourcei(impl_channels[i].sid, AL_BUFFER, 0);
+ alDeleteSources(1, &impl_channels[i].sid);
}
ALCdevice *dev = alcGetContextsDevice(ctx);
alcMakeContextCurrent(NULL);
}
num_channels = 0;
- delete[] channels;
- channels = NULL;
+ delete[] impl_channels;
+ impl_channels = NULL;
unload_alsyms();
initialized = false;
{
if (!initialized) return NULL;
if ((channel < 0) || (channel >= num_channels)) return NULL;
- return channels[channel].sample;
+ return impl_channels[channel].sample;
}
AL_API signed char OPENAL_GetPaused(int channel)
{
if (!initialized) return false;
if ((channel < 0) || (channel >= num_channels)) return false;
- if (channels[channel].startpaused)
+ if (impl_channels[channel].startpaused)
return(true);
ALint state = 0;
- alGetSourceiv(channels[channel].sid, AL_SOURCE_STATE, &state);
+ alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
return((state == AL_PAUSED) ? true : false);
}
if (!initialized) return 0;
if ((channel < 0) || (channel >= num_channels)) return 0;
ALint loop = 0;
- alGetSourceiv(channels[channel].sid, AL_LOOPING, &loop);
+ alGetSourceiv(impl_channels[channel].sid, AL_LOOPING, &loop);
if (loop)
return(OPENAL_LOOP_NORMAL);
return OPENAL_LOOP_OFF;
if (!initialized) return false;
if ((channel < 0) || (channel >= num_channels)) return false;
ALint state = 0;
- alGetSourceiv(channels[channel].sid, AL_SOURCE_STATE, &state);
+ alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
return((state == AL_PLAYING) ? true : false);
}
for (int i = 0; i < num_channels; i++)
{
ALint state = 0;
- alGetSourceiv(channels[i].sid, AL_SOURCE_STATE, &state);
+ alGetSourceiv(impl_channels[i].sid, AL_SOURCE_STATE, &state);
if ((state != AL_PLAYING) && (state != AL_PAUSED))
{
channel = i;
}
if ((channel < 0) || (channel >= num_channels)) return -1;
- alSourceStop(channels[channel].sid);
- channels[channel].sample = sptr;
- alSourcei(channels[channel].sid, AL_BUFFER, sptr->bid);
- alSourcei(channels[channel].sid, AL_LOOPING, (sptr->mode == OPENAL_LOOP_OFF) ? AL_FALSE : AL_TRUE);
+ alSourceStop(impl_channels[channel].sid);
+ impl_channels[channel].sample = sptr;
+ alSourcei(impl_channels[channel].sid, AL_BUFFER, sptr->bid);
+ alSourcei(impl_channels[channel].sid, AL_LOOPING, (sptr->mode == OPENAL_LOOP_OFF) ? AL_FALSE : AL_TRUE);
set_channel_position(channel, 0.0f, 0.0f, 0.0f);
- channels[channel].startpaused = ((startpaused) ? true : false);
+ impl_channels[channel].startpaused = ((startpaused) ? true : false);
if (!startpaused)
- alSourcePlay(channels[channel].sid);
+ alSourcePlay(impl_channels[channel].sid);
return channel;
}
{
for (int i = 0; i < num_channels; i++)
{
- if (channels[i].sample == sptr)
+ if (impl_channels[i].sample == sptr)
{
- alSourceStop(channels[i].sid);
- alSourcei(channels[i].sid, AL_BUFFER, 0);
- channels[i].sample = NULL;
+ alSourceStop(impl_channels[i].sid);
+ alSourcei(impl_channels[i].sid, AL_BUFFER, 0);
+ impl_channels[i].sample = NULL;
}
}
alDeleteBuffers(1, &sptr->bid);
if ((channel < 0) || (channel >= num_channels)) return false;
if (freq == 8012) // hack
- alSourcef(channels[channel].sid, AL_PITCH, 8012.0f / 44100.0f);
+ alSourcef(impl_channels[channel].sid, AL_PITCH, 8012.0f / 44100.0f);
else
- alSourcef(channels[channel].sid, AL_PITCH, 1.0f);
+ alSourcef(impl_channels[channel].sid, AL_PITCH, 1.0f);
return true;
}
if (vol < 0) vol = 0;
else if (vol > 255) vol = 255;
ALfloat gain = ((ALfloat) vol) / 255.0f;
- alSourcef(channels[channel].sid, AL_GAIN, gain);
+ alSourcef(impl_channels[channel].sid, AL_GAIN, gain);
return true;
}
if ((channel < 0) || (channel >= num_channels)) return false;
ALint state = 0;
- if (channels[channel].startpaused)
+ if (impl_channels[channel].startpaused)
state = AL_PAUSED;
else
- alGetSourceiv(channels[channel].sid, AL_SOURCE_STATE, &state);
+ alGetSourceiv(impl_channels[channel].sid, AL_SOURCE_STATE, &state);
if ((paused) && (state == AL_PLAYING))
- alSourcePause(channels[channel].sid);
+ alSourcePause(impl_channels[channel].sid);
else if ((!paused) && (state == AL_PAUSED))
{
- alSourcePlay(channels[channel].sid);
- channels[channel].startpaused = false;
+ alSourcePlay(impl_channels[channel].sid);
+ impl_channels[channel].startpaused = false;
}
return true;
}
}
if ((channel < 0) || (channel >= num_channels)) return false;
- alSourceStop(channels[channel].sid);
- channels[channel].startpaused = false;
+ alSourceStop(impl_channels[channel].sid);
+ impl_channels[channel].startpaused = false;
return true;
}
if (!initialized) return false;
for (int i = 0; i < num_channels; i++)
{
- if (channels[i].sample == (OPENAL_SAMPLE *) stream)
+ if (impl_channels[i].sample == (OPENAL_SAMPLE *) stream)
{
- alSourceStop(channels[i].sid);
- channels[i].startpaused = false;
+ alSourceStop(impl_channels[i].sid);
+ impl_channels[i].startpaused = false;
}
}
return true;