Added additional comments to AudioDevice.cpp, removed unnecessary checks from AudioDevice setters.
This commit is contained in:
parent
0ad401cc97
commit
c4e450cac4
@ -104,9 +104,12 @@ AudioDevice::~AudioDevice()
|
|||||||
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
bool AudioDevice::isExtensionSupported(const std::string& extension)
|
||||||
{
|
{
|
||||||
// Create a temporary audio device in case none exists yet.
|
// Create a temporary audio device in case none exists yet.
|
||||||
|
// This device will not be used in this function and merely
|
||||||
|
// makes sure there is a valid OpenAL device for extension
|
||||||
|
// queries if none has been created yet.
|
||||||
std::auto_ptr<AudioDevice> device;
|
std::auto_ptr<AudioDevice> device;
|
||||||
if (!audioDevice)
|
if (!audioDevice)
|
||||||
device = std::auto_ptr<AudioDevice>(new AudioDevice);
|
device.reset(new AudioDevice);
|
||||||
|
|
||||||
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
|
||||||
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
|
||||||
@ -119,9 +122,12 @@ bool AudioDevice::isExtensionSupported(const std::string& extension)
|
|||||||
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
||||||
{
|
{
|
||||||
// Create a temporary audio device in case none exists yet.
|
// Create a temporary audio device in case none exists yet.
|
||||||
|
// This device will not be used in this function and merely
|
||||||
|
// makes sure there is a valid OpenAL device for format
|
||||||
|
// queries if none has been created yet.
|
||||||
std::auto_ptr<AudioDevice> device;
|
std::auto_ptr<AudioDevice> device;
|
||||||
if (!audioDevice)
|
if (!audioDevice)
|
||||||
device = std::auto_ptr<AudioDevice>(new AudioDevice);
|
device.reset(new AudioDevice);
|
||||||
|
|
||||||
// Find the good format according to the number of channels
|
// Find the good format according to the number of channels
|
||||||
int format = 0;
|
int format = 0;
|
||||||
@ -146,15 +152,12 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void AudioDevice::setGlobalVolume(float volume)
|
void AudioDevice::setGlobalVolume(float volume)
|
||||||
{
|
|
||||||
if (volume != listenerVolume)
|
|
||||||
{
|
{
|
||||||
if (audioContext)
|
if (audioContext)
|
||||||
alCheck(alListenerf(AL_GAIN, volume * 0.01f));
|
alCheck(alListenerf(AL_GAIN, volume * 0.01f));
|
||||||
|
|
||||||
listenerVolume = volume;
|
listenerVolume = volume;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -166,15 +169,12 @@ float AudioDevice::getGlobalVolume()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void AudioDevice::setPosition(const Vector3f& position)
|
void AudioDevice::setPosition(const Vector3f& position)
|
||||||
{
|
|
||||||
if (position != listenerPosition)
|
|
||||||
{
|
{
|
||||||
if (audioContext)
|
if (audioContext)
|
||||||
alCheck(alListener3f(AL_POSITION, position.x, position.y, position.z));
|
alCheck(alListener3f(AL_POSITION, position.x, position.y, position.z));
|
||||||
|
|
||||||
listenerPosition = position;
|
listenerPosition = position;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -186,8 +186,6 @@ Vector3f AudioDevice::getPosition()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void AudioDevice::setDirection(const Vector3f& direction)
|
void AudioDevice::setDirection(const Vector3f& direction)
|
||||||
{
|
|
||||||
if (direction != listenerDirection)
|
|
||||||
{
|
{
|
||||||
if (audioContext)
|
if (audioContext)
|
||||||
{
|
{
|
||||||
@ -197,7 +195,6 @@ void AudioDevice::setDirection(const Vector3f& direction)
|
|||||||
|
|
||||||
listenerDirection = direction;
|
listenerDirection = direction;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -209,8 +206,6 @@ Vector3f AudioDevice::getDirection()
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void AudioDevice::setUpVector(const Vector3f& upVector)
|
void AudioDevice::setUpVector(const Vector3f& upVector)
|
||||||
{
|
|
||||||
if (upVector != listenerUpVector)
|
|
||||||
{
|
{
|
||||||
if (audioContext)
|
if (audioContext)
|
||||||
{
|
{
|
||||||
@ -220,7 +215,6 @@ void AudioDevice::setUpVector(const Vector3f& upVector)
|
|||||||
|
|
||||||
listenerUpVector = upVector;
|
listenerUpVector = upVector;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user