summaryrefslogtreecommitdiffstats
path: root/src/audio/oal/channel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/oal/channel.cpp')
-rw-r--r--src/audio/oal/channel.cpp59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/audio/oal/channel.cpp b/src/audio/oal/channel.cpp
index d8b50161..7742a06a 100644
--- a/src/audio/oal/channel.cpp
+++ b/src/audio/oal/channel.cpp
@@ -1,20 +1,21 @@
#include "channel.h"
#ifdef AUDIO_OAL
+#include "common.h"
#include "sampman.h"
extern bool IsFXSupported();
CChannel::CChannel()
{
- alChannel = AL_NONE;
+ alSource = AL_NONE;
alFilter = AL_FILTER_NULL;
SetDefault();
}
void CChannel::SetDefault()
{
- Buffer = AL_NONE;
+ alBuffer = AL_NONE;
Pitch = 1.0f;
Gain = 1.0f;
@@ -37,17 +38,17 @@ void CChannel::Reset()
void CChannel::Init(bool Is2D)
{
ASSERT(!HasSource());
- alGenSources(1, &alChannel);
+ alGenSources(1, &alSource);
if ( HasSource() )
{
- alSourcei(alChannel, AL_SOURCE_RELATIVE, AL_TRUE);
+ alSourcei(alSource, AL_SOURCE_RELATIVE, AL_TRUE);
if ( IsFXSupported() )
- alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
+ alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
if ( Is2D )
{
- alSource3f(alChannel, AL_POSITION, 0.0f, 0.0f, 0.0f);
- alSourcef (alChannel, AL_GAIN, 1.0f);
+ alSource3f(alSource, AL_POSITION, 0.0f, 0.0f, 0.0f);
+ alSourcef (alSource, AL_GAIN, 1.0f);
}
else
{
@@ -64,15 +65,15 @@ void CChannel::Term()
{
if ( IsFXSupported() )
{
- alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
+ alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, AL_EFFECTSLOT_NULL, 0, AL_FILTER_NULL);
if(alFilter != AL_FILTER_NULL)
alDeleteFilters(1,&alFilter);
}
- alDeleteSources(1, &alChannel);
+ alDeleteSources(1, &alSource);
}
- alChannel = AL_NONE;
+ alSource = AL_NONE;
alFilter = AL_FILTER_NULL;
}
@@ -81,22 +82,22 @@ void CChannel::Start()
if ( !HasSource() ) return;
if ( LoopPoints[0] != 0 && LoopPoints[0] != -1 )
- alBufferiv(Buffer, AL_LOOP_POINTS_SOFT, LoopPoints);
- alSourcei (alChannel, AL_BUFFER, Buffer);
- alSourcePlay(alChannel);
+ alBufferiv(alBuffer, AL_LOOP_POINTS_SOFT, LoopPoints);
+ alSourcei (alSource, AL_BUFFER, alBuffer);
+ alSourcePlay(alSource);
}
void CChannel::Stop()
{
if ( HasSource() )
- alSourceStop(alChannel);
+ alSourceStop(alSource);
Reset();
}
bool CChannel::HasSource()
{
- return alChannel != AL_NONE;
+ return alSource != AL_NONE;
}
bool CChannel::IsUsed()
@@ -104,7 +105,7 @@ bool CChannel::IsUsed()
if ( HasSource() )
{
ALint sourceState;
- alGetSourcei(alChannel, AL_SOURCE_STATE, &sourceState);
+ alGetSourcei(alSource, AL_SOURCE_STATE, &sourceState);
return sourceState == AL_PLAYING;
}
return false;
@@ -113,13 +114,13 @@ bool CChannel::IsUsed()
void CChannel::SetPitch(float pitch)
{
if ( !HasSource() ) return;
- alSourcef(alChannel, AL_PITCH, pitch);
+ alSourcef(alSource, AL_PITCH, pitch);
}
void CChannel::SetGain(float gain)
{
if ( !HasSource() ) return;
- alSourcef(alChannel, AL_GAIN, gain);
+ alSourcef(alSource, AL_GAIN, gain);
}
void CChannel::SetVolume(int32 vol)
@@ -145,7 +146,7 @@ void CChannel::SetCurrentFreq(uint32 freq)
void CChannel::SetLoopCount(int32 loopCount) // fake. TODO:
{
if ( !HasSource() ) return;
- alSourcei(alChannel, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE);
+ alSourcei(alSource, AL_LOOPING, loopCount == 1 ? AL_FALSE : AL_TRUE);
}
void CChannel::SetLoopPoints(ALint start, ALint end)
@@ -157,33 +158,33 @@ void CChannel::SetLoopPoints(ALint start, ALint end)
void CChannel::SetPosition(float x, float y, float z)
{
if ( !HasSource() ) return;
- alSource3f(alChannel, AL_POSITION, x, y, z);
+ alSource3f(alSource, AL_POSITION, x, y, z);
}
void CChannel::SetDistances(float max, float min)
{
if ( !HasSource() ) return;
- alSourcef (alChannel, AL_MAX_DISTANCE, max);
- alSourcef (alChannel, AL_REFERENCE_DISTANCE, min);
- alSourcef (alChannel, AL_MAX_GAIN, 1.0f);
- alSourcef (alChannel, AL_ROLLOFF_FACTOR, 1.0f);
+ alSourcef (alSource, AL_MAX_DISTANCE, max);
+ alSourcef (alSource, AL_REFERENCE_DISTANCE, min);
+ alSourcef (alSource, AL_MAX_GAIN, 1.0f);
+ alSourcef (alSource, AL_ROLLOFF_FACTOR, 1.0f);
}
void CChannel::SetPan(uint32 pan)
{
- SetPosition((pan-63)/64.0f, 0.0f, sqrtf(1.0f-SQR((pan-63)/64.0f)));
+ SetPosition((pan-63)/64.0f, 0.0f, Sqrt(1.0f-SQR((pan-63)/64.0f)));
}
void CChannel::SetBuffer(ALuint buffer)
{
- Buffer = buffer;
+ alBuffer = buffer;
}
void CChannel::ClearBuffer()
{
if ( !HasSource() ) return;
SetBuffer(AL_NONE);
- alSourcei(alChannel, AL_BUFFER, AL_NONE);
+ alSourcei(alSource, AL_BUFFER, AL_NONE);
}
void CChannel::SetReverbMix(ALuint slot, float mix)
@@ -194,7 +195,7 @@ void CChannel::SetReverbMix(ALuint slot, float mix)
Mix = mix;
EAX3_SetReverbMix(alFilter, mix);
- alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter);
+ alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter);
}
void CChannel::UpdateReverb(ALuint slot)
@@ -203,7 +204,7 @@ void CChannel::UpdateReverb(ALuint slot)
if ( !HasSource() ) return;
if ( alFilter == AL_FILTER_NULL ) return;
EAX3_SetReverbMix(alFilter, Mix);
- alSource3i(alChannel, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter);
+ alSource3i(alSource, AL_AUXILIARY_SEND_FILTER, slot, 0, alFilter);
}
#endif \ No newline at end of file