Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/audaspace')
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp389
-rw-r--r--intern/audaspace/intern/AUD_C-API.cpp38
-rw-r--r--intern/audaspace/intern/AUD_C-API.h23
-rw-r--r--intern/audaspace/intern/AUD_SoftwareDevice.cpp194
-rw-r--r--intern/audaspace/make/msvc_9_0/audaspace.vcproj1
5 files changed, 395 insertions, 250 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index b33afa2b955..aa9f425d6fb 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -127,101 +127,103 @@ void AUD_OpenALDevice::updateStreams()
alcSuspendContext(m_context);
- // for all sounds
- AUD_HandleIterator it = m_playingSounds->begin();
- while(it != m_playingSounds->end())
{
- sound = *it;
- // increment the iterator to make sure it's valid,
- // in case the sound gets deleted after stopping
- ++it;
-
- // is it a streamed sound?
- if(!sound->isBuffered)
+ // for all sounds
+ AUD_HandleIterator it = m_playingSounds->begin();
+ while(it != m_playingSounds->end())
{
- // check for buffer refilling
- alGetSourcei(sound->source, AL_BUFFERS_PROCESSED, &info);
+ sound = *it;
+ // increment the iterator to make sure it's valid,
+ // in case the sound gets deleted after stopping
+ ++it;
- if(info)
+ // is it a streamed sound?
+ if(!sound->isBuffered)
{
- specs = sound->reader->getSpecs();
+ // check for buffer refilling
+ alGetSourcei(sound->source, AL_BUFFERS_PROCESSED, &info);
- // for all empty buffers
- while(info--)
+ if(info)
{
- // if there's still data to play back
- if(!sound->data_end)
- {
- // read data
- length = m_buffersize;
- sound->reader->read(length, buffer);
-
- // read nothing?
- if(length == 0)
- {
- sound->data_end = true;
- break;
- }
-
- // unqueue buffer
- alSourceUnqueueBuffers(sound->source, 1,
- &sound->buffers[sound->current]);
- ALenum err;
- if((err = alGetError()) != AL_NO_ERROR)
- {
- sound->data_end = true;
- break;
- }
-
- // fill with new data
- alBufferData(sound->buffers[sound->current],
- sound->format,
- buffer,
- length * AUD_SAMPLE_SIZE(specs),
- specs.rate);
+ specs = sound->reader->getSpecs();
- if(alGetError() != AL_NO_ERROR)
+ // for all empty buffers
+ while(info--)
+ {
+ // if there's still data to play back
+ if(!sound->data_end)
{
- sound->data_end = true;
- break;
+ // read data
+ length = m_buffersize;
+ sound->reader->read(length, buffer);
+
+ // read nothing?
+ if(length == 0)
+ {
+ sound->data_end = true;
+ break;
+ }
+
+ // unqueue buffer
+ alSourceUnqueueBuffers(sound->source, 1,
+ &sound->buffers[sound->current]);
+ ALenum err;
+ if((err = alGetError()) != AL_NO_ERROR)
+ {
+ sound->data_end = true;
+ break;
+ }
+
+ // fill with new data
+ alBufferData(sound->buffers[sound->current],
+ sound->format,
+ buffer,
+ length * AUD_SAMPLE_SIZE(specs),
+ specs.rate);
+
+ if(alGetError() != AL_NO_ERROR)
+ {
+ sound->data_end = true;
+ break;
+ }
+
+ // and queue again
+ alSourceQueueBuffers(sound->source, 1,
+ &sound->buffers[sound->current]);
+ if(alGetError() != AL_NO_ERROR)
+ {
+ sound->data_end = true;
+ break;
+ }
+
+ sound->current = (sound->current+1) %
+ AUD_OPENAL_CYCLE_BUFFERS;
}
-
- // and queue again
- alSourceQueueBuffers(sound->source, 1,
- &sound->buffers[sound->current]);
- if(alGetError() != AL_NO_ERROR)
- {
- sound->data_end = true;
+ else
break;
- }
-
- sound->current = (sound->current+1) %
- AUD_OPENAL_CYCLE_BUFFERS;
}
- else
- break;
}
}
- }
- // check if the sound has been stopped
- alGetSourcei(sound->source, AL_SOURCE_STATE, &info);
+ // check if the sound has been stopped
+ alGetSourcei(sound->source, AL_SOURCE_STATE, &info);
- if(info != AL_PLAYING)
- {
- // if it really stopped
- if(sound->data_end)
+ if(info != AL_PLAYING)
{
- // pause or
- if(sound->keep)
- pause(sound);
- // stop
+ // if it really stopped
+ if(sound->data_end)
+ {
+ // pause or
+ if(sound->keep)
+ pause(sound);
+ // stop
+ else
+ stop(sound);
+ }
+ // continue playing
else
- stop(sound);
+ alSourcePlay(sound->source);
}
- // continue playing
- else
- alSourcePlay(sound->source);
}
}
@@ -516,60 +518,73 @@ bool AUD_OpenALDevice::getFormat(ALenum &format, AUD_Specs specs)
AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
{
- // check if it is a buffered factory
- for(AUD_BFIterator i = m_bufferedFactories->begin();
- i != m_bufferedFactories->end(); i++)
- {
- if((*i)->factory == factory)
- {
- // create the handle
- AUD_OpenALHandle* sound = new AUD_OpenALHandle; AUD_NEW("handle")
- sound->keep = keep;
- sound->current = -1;
- sound->isBuffered = true;
- sound->data_end = true;
+ lock();
- alcSuspendContext(m_context);
+ AUD_OpenALHandle* sound = NULL;
- // OpenAL playback code
- try
+ try
+ {
+ // check if it is a buffered factory
+ for(AUD_BFIterator i = m_bufferedFactories->begin();
+ i != m_bufferedFactories->end(); i++)
+ {
+ if((*i)->factory == factory)
{
- alGenSources(1, &sound->source);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL);
+ // create the handle
+ sound = new AUD_OpenALHandle; AUD_NEW("handle")
+ sound->keep = keep;
+ sound->current = -1;
+ sound->isBuffered = true;
+ sound->data_end = true;
+
+ alcSuspendContext(m_context);
+ // OpenAL playback code
try
{
- alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
+ alGenSources(1, &sound->source);
if(alGetError() != AL_NO_ERROR)
AUD_THROW(AUD_ERROR_OPENAL);
+
+ try
+ {
+ alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(AUD_ERROR_OPENAL);
+ }
+ catch(AUD_Exception)
+ {
+ alDeleteSources(1, &sound->source);
+ throw;
+ }
}
catch(AUD_Exception)
{
- alDeleteSources(1, &sound->source);
+ delete sound; AUD_DELETE("handle")
+ alcProcessContext(m_context);
throw;
}
- }
- catch(AUD_Exception)
- {
- delete sound; AUD_DELETE("handle")
- alcProcessContext(m_context);
- unlock();
- throw;
- }
- // play sound
- m_playingSounds->push_back(sound);
+ // play sound
+ m_playingSounds->push_back(sound);
- alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
- start();
+ alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
+ start();
- alcProcessContext(m_context);
- unlock();
-
- return sound;
+ alcProcessContext(m_context);
+ }
}
}
+ catch(AUD_Exception)
+ {
+ unlock();
+ throw;
+ }
+
+ unlock();
+
+ if(sound)
+ return sound;
AUD_IReader* reader = factory->createReader();
@@ -596,7 +611,7 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
}
// create the handle
- AUD_OpenALHandle* sound = new AUD_OpenALHandle; AUD_NEW("handle")
+ sound = new AUD_OpenALHandle; AUD_NEW("handle")
sound->keep = keep;
sound->reader = reader;
sound->current = 0;
@@ -683,8 +698,11 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
bool AUD_OpenALDevice::pause(AUD_Handle* handle)
{
- // only songs that are played can be paused
+ bool result = false;
+
lock();
+
+ // only songs that are played can be paused
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
@@ -693,16 +711,20 @@ bool AUD_OpenALDevice::pause(AUD_Handle* handle)
m_pausedSounds->push_back(*i);
alSourcePause((*i)->source);
m_playingSounds->erase(i);
- unlock();
- return true;
+ result = true;
+ break;
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_OpenALDevice::resume(AUD_Handle* handle)
{
+ bool result = false;
+
lock();
// only songs that are paused can be resumed
@@ -714,19 +736,24 @@ bool AUD_OpenALDevice::resume(AUD_Handle* handle)
m_playingSounds->push_back(*i);
start();
m_pausedSounds->erase(i);
- unlock();
- return true;
+ result = true;
+ break;
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_OpenALDevice::stop(AUD_Handle* handle)
{
AUD_OpenALHandle* sound;
+ bool result = false;
+
lock();
+
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
@@ -741,51 +768,60 @@ bool AUD_OpenALDevice::stop(AUD_Handle* handle)
}
delete *i; AUD_DELETE("handle")
m_playingSounds->erase(i);
- unlock();
- return true;
+ result = true;
+ break;
}
}
- for(AUD_HandleIterator i = m_pausedSounds->begin();
- i != m_pausedSounds->end(); i++)
+ if(!result)
{
- if(*i == handle)
+ for(AUD_HandleIterator i = m_pausedSounds->begin();
+ i != m_pausedSounds->end(); i++)
{
- sound = *i;
- alDeleteSources(1, &sound->source);
- if(!sound->isBuffered)
+ if(*i == handle)
{
- delete sound->reader; AUD_DELETE("reader")
- alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers);
+ sound = *i;
+ alDeleteSources(1, &sound->source);
+ if(!sound->isBuffered)
+ {
+ delete sound->reader; AUD_DELETE("reader")
+ alDeleteBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers);
+ }
+ delete *i; AUD_DELETE("handle")
+ m_pausedSounds->erase(i);
+ result = true;
+ break;
}
- delete *i; AUD_DELETE("handle")
- m_pausedSounds->erase(i);
- unlock();
- return true;
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_OpenALDevice::setKeep(AUD_Handle* handle, bool keep)
{
+ bool result = false;
+
lock();
+
if(isValid(handle))
{
((AUD_OpenALHandle*)handle)->keep = keep;
- unlock();
- return true;
+ result = true;
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_OpenALDevice::sendMessage(AUD_Handle* handle, AUD_Message &message)
{
- lock();
-
bool result = false;
+ lock();
+
if(handle == 0)
{
for(AUD_HandleIterator i = m_playingSounds->begin();
@@ -800,12 +836,16 @@ bool AUD_OpenALDevice::sendMessage(AUD_Handle* handle, AUD_Message &message)
else if(isValid(handle))
if(!((AUD_OpenALHandle*)handle)->isBuffered)
result = ((AUD_OpenALHandle*)handle)->reader->notify(message);
+
unlock();
+
return result;
}
bool AUD_OpenALDevice::seek(AUD_Handle* handle, float position)
{
+ bool result = false;
+
lock();
if(isValid(handle))
@@ -857,20 +897,19 @@ bool AUD_OpenALDevice::seek(AUD_Handle* handle, float position)
alSourceRewind(alhandle->source);
}
}
- unlock();
- return true;
+ result = true;
}
unlock();
- return false;
+ return result;
}
float AUD_OpenALDevice::getPosition(AUD_Handle* handle)
{
- lock();
-
float position = 0.0;
+ lock();
+
if(isValid(handle))
{
AUD_OpenALHandle* h = (AUD_OpenALHandle*)handle;
@@ -887,27 +926,35 @@ float AUD_OpenALDevice::getPosition(AUD_Handle* handle)
AUD_Status AUD_OpenALDevice::getStatus(AUD_Handle* handle)
{
+ AUD_Status status = AUD_STATUS_INVALID;
+
lock();
+
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
if(*i == handle)
{
- unlock();
- return AUD_STATUS_PLAYING;
+ status = AUD_STATUS_PLAYING;
+ break;
}
}
- for(AUD_HandleIterator i = m_pausedSounds->begin();
- i != m_pausedSounds->end(); i++)
+ if(status == AUD_STATUS_INVALID)
{
- if(*i == handle)
+ for(AUD_HandleIterator i = m_pausedSounds->begin();
+ i != m_pausedSounds->end(); i++)
{
- unlock();
- return AUD_STATUS_PAUSED;
+ if(*i == handle)
+ {
+ status = AUD_STATUS_PAUSED;
+ break;
+ }
}
}
+
unlock();
- return AUD_STATUS_INVALID;
+
+ return status;
}
void AUD_OpenALDevice::lock()
@@ -935,6 +982,7 @@ bool AUD_OpenALDevice::checkCapability(int capability)
bool AUD_OpenALDevice::setCapability(int capability, void *value)
{
+ bool result = false;
switch(capability)
{
case AUD_CAPS_VOLUME:
@@ -948,8 +996,7 @@ bool AUD_OpenALDevice::setCapability(int capability, void *value)
{
alSourcef(((AUD_OpenALHandle*)caps->handle)->source,
AL_GAIN, caps->value);
- unlock();
- return true;
+ result = true;
}
unlock();
}
@@ -962,8 +1009,7 @@ bool AUD_OpenALDevice::setCapability(int capability, void *value)
{
alSourcef(((AUD_OpenALHandle*)caps->handle)->source,
AL_PITCH, caps->value);
- unlock();
- return true;
+ result = true;
}
unlock();
}
@@ -981,11 +1027,13 @@ bool AUD_OpenALDevice::setCapability(int capability, void *value)
{
if((*i)->factory == factory)
{
- unlock();
- return true;
+ result = true;
+ break;
}
}
unlock();
+ if(result)
+ return result;
AUD_IReader* reader = factory->createReader();
@@ -1104,11 +1152,13 @@ bool AUD_OpenALDevice::setCapability(int capability, void *value)
}
break;
}
- return false;
+ return result;
}
bool AUD_OpenALDevice::getCapability(int capability, void *value)
{
+ bool result = false;
+
switch(capability)
{
case AUD_CAPS_VOLUME:
@@ -1122,8 +1172,7 @@ bool AUD_OpenALDevice::getCapability(int capability, void *value)
{
alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source,
AL_GAIN, &caps->value);
- unlock();
- return true;
+ result = true;
}
unlock();
}
@@ -1136,14 +1185,14 @@ bool AUD_OpenALDevice::getCapability(int capability, void *value)
{
alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source,
AL_PITCH, &caps->value);
- unlock();
- return true;
+ result = true;
}
unlock();
}
break;
}
- return false;
+
+ return result;
}
/******************************************************************************/
@@ -1233,6 +1282,8 @@ float AUD_OpenALDevice::getSetting(AUD_3DSetting setting)
bool AUD_OpenALDevice::updateSource(AUD_Handle* handle, AUD_3DData &data)
{
+ bool result = false;
+
lock();
if(isValid(handle))
@@ -1241,12 +1292,12 @@ bool AUD_OpenALDevice::updateSource(AUD_Handle* handle, AUD_3DData &data)
alSourcefv(source, AL_POSITION, (ALfloat*)data.position);
alSourcefv(source, AL_VELOCITY, (ALfloat*)data.velocity);
alSourcefv(source, AL_DIRECTION, (ALfloat*)&(data.orientation[3]));
- unlock();
- return true;
+ result = true;
}
unlock();
- return false;
+
+ return result;
}
bool AUD_OpenALDevice::setSourceSetting(AUD_Handle* handle,
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp
index 45faebc7e97..255d1d2f1f6 100644
--- a/intern/audaspace/intern/AUD_C-API.cpp
+++ b/intern/audaspace/intern/AUD_C-API.cpp
@@ -516,19 +516,51 @@ AUD_Device* AUD_openReadDevice(AUD_Specs specs)
}
}
-int AUD_playDevice(AUD_Device* device, AUD_Sound* sound)
+AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound)
{
assert(device);
assert(sound);
try
{
- return device->play(sound) != NULL;
+ return device->play(sound);
}
catch(AUD_Exception)
{
- return false;
+ return NULL;
+ }
+}
+
+int AUD_setDeviceVolume(AUD_Device* device, float volume)
+{
+ assert(device);
+
+ try
+ {
+ return device->setCapability(AUD_CAPS_VOLUME, &volume);
+ }
+ catch(AUD_Exception) {}
+
+ return false;
+}
+
+int AUD_setDeviceSoundVolume(AUD_Device* device, AUD_Handle* handle,
+ float volume)
+{
+ if(handle)
+ {
+ assert(device);
+ AUD_SourceCaps caps;
+ caps.handle = handle;
+ caps.value = volume;
+
+ try
+ {
+ return device->setCapability(AUD_CAPS_SOURCE_VOLUME, &caps);
+ }
+ catch(AUD_Exception) {}
}
+ return false;
}
int AUD_readDevice(AUD_Device* device, sample_t* buffer, int length)
diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h
index 6ec5ec87ad5..66a5a5147b3 100644
--- a/intern/audaspace/intern/AUD_C-API.h
+++ b/intern/audaspace/intern/AUD_C-API.h
@@ -300,12 +300,31 @@ extern int AUD_setSoundPitch(AUD_Handle* handle, float pitch);
extern AUD_Device* AUD_openReadDevice(AUD_Specs specs);
/**
+ * Sets the main volume of a device.
+ * \param device The device.
+ * \param volume The new volume, must be between 0.0 and 1.0.
+ * \return Whether the action succeeded.
+ */
+extern int AUD_setDeviceVolume(AUD_Device* device, float volume);
+
+/**
* Plays back a sound file through a read device.
* \param device The read device.
* \param sound The handle of the sound file.
- * \return Whether the sound could be played back.
+ * \return A handle to the played back sound.
+ */
+extern AUD_Handle* AUD_playDevice(AUD_Device* device, AUD_Sound* sound);
+
+/**
+ * Sets the volume of a played back sound of a read device.
+ * \param device The read device.
+ * \param handle The handle to the sound.
+ * \param volume The new volume, must be between 0.0 and 1.0.
+ * \return Whether the action succeeded.
*/
-extern int AUD_playDevice(AUD_Device* device, AUD_Sound* sound);
+extern int AUD_setDeviceSoundVolume(AUD_Device* device,
+ AUD_Handle* handle,
+ float volume);
/**
* Reads the next samples into the supplied buffer.
diff --git a/intern/audaspace/intern/AUD_SoftwareDevice.cpp b/intern/audaspace/intern/AUD_SoftwareDevice.cpp
index 174ff8c8979..42a90a6f15e 100644
--- a/intern/audaspace/intern/AUD_SoftwareDevice.cpp
+++ b/intern/audaspace/intern/AUD_SoftwareDevice.cpp
@@ -94,51 +94,53 @@ void AUD_SoftwareDevice::mix(sample_t* buffer, int length)
{
lock();
- AUD_SoftwareHandle* sound;
- int len;
- sample_t* buf;
- int sample_size = AUD_SAMPLE_SIZE(m_specs);
- std::list<AUD_SoftwareHandle*> stopSounds;
-
- // for all sounds
- AUD_HandleIterator it = m_playingSounds->begin();
- while(it != m_playingSounds->end())
{
- sound = *it;
- // increment the iterator to make sure it's valid,
- // in case the sound gets deleted after stopping
- ++it;
+ AUD_SoftwareHandle* sound;
+ int len;
+ sample_t* buf;
+ int sample_size = AUD_SAMPLE_SIZE(m_specs);
+ std::list<AUD_SoftwareHandle*> stopSounds;
+
+ // for all sounds
+ AUD_HandleIterator it = m_playingSounds->begin();
+ while(it != m_playingSounds->end())
+ {
+ sound = *it;
+ // increment the iterator to make sure it's valid,
+ // in case the sound gets deleted after stopping
+ ++it;
- // get the buffer from the source
- len = length;
- sound->reader->read(len, buf);
+ // get the buffer from the source
+ len = length;
+ sound->reader->read(len, buf);
- m_mixer->add(buf, sound->reader->getSpecs(), len, sound->volume);
+ m_mixer->add(buf, sound->reader->getSpecs(), len, sound->volume);
- // in case the end of the sound is reached
- if(len < length)
- {
- if(sound->keep)
- pause(sound);
- else
- stopSounds.push_back(sound);
+ // in case the end of the sound is reached
+ if(len < length)
+ {
+ if(sound->keep)
+ pause(sound);
+ else
+ stopSounds.push_back(sound);
+ }
}
- }
- // fill with silence
- if(m_specs.format == AUD_FORMAT_U8)
- memset(buffer, 0x80, length * sample_size);
- else
- memset(buffer, 0, length * sample_size);
+ // fill with silence
+ if(m_specs.format == AUD_FORMAT_U8)
+ memset(buffer, 0x80, length * sample_size);
+ else
+ memset(buffer, 0, length * sample_size);
- // superpose
- m_mixer->superpose(buffer, length, m_volume);
+ // superpose
+ m_mixer->superpose(buffer, length, m_volume);
- while(!stopSounds.empty())
- {
- sound = stopSounds.front();
- stopSounds.pop_front();
- stop(sound);
+ while(!stopSounds.empty())
+ {
+ sound = stopSounds.front();
+ stopSounds.pop_front();
+ stop(sound);
+ }
}
unlock();
@@ -201,8 +203,11 @@ AUD_Handle* AUD_SoftwareDevice::play(AUD_IFactory* factory, bool keep)
bool AUD_SoftwareDevice::pause(AUD_Handle* handle)
{
- // only songs that are played can be paused
+ bool result = false;
+
lock();
+
+ // only songs that are played can be paused
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
@@ -212,18 +217,23 @@ bool AUD_SoftwareDevice::pause(AUD_Handle* handle)
m_playingSounds->erase(i);
if(m_playingSounds->empty())
playing(m_playback = false);
- unlock();
- return true;
+ result = true;
+ break;
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_SoftwareDevice::resume(AUD_Handle* handle)
{
- // only songs that are paused can be resumed
+ bool result = false;
+
lock();
+
+ // only songs that are paused can be resumed
for(AUD_HandleIterator i = m_pausedSounds->begin();
i != m_pausedSounds->end(); i++)
{
@@ -233,17 +243,22 @@ bool AUD_SoftwareDevice::resume(AUD_Handle* handle)
m_pausedSounds->erase(i);
if(!m_playback)
playing(m_playback = true);
- unlock();
- return true;
+ result = true;
+ break;
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_SoftwareDevice::stop(AUD_Handle* handle)
{
+ bool result = false;
+
lock();
+
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
@@ -254,37 +269,46 @@ bool AUD_SoftwareDevice::stop(AUD_Handle* handle)
m_playingSounds->erase(i);
if(m_playingSounds->empty())
playing(m_playback = false);
- unlock();
- return true;
+ result = true;
+ break;
}
}
- for(AUD_HandleIterator i = m_pausedSounds->begin();
- i != m_pausedSounds->end(); i++)
+ if(!result)
{
- if(*i == handle)
+ for(AUD_HandleIterator i = m_pausedSounds->begin();
+ i != m_pausedSounds->end(); i++)
{
- delete (*i)->reader; AUD_DELETE("reader")
- delete *i; AUD_DELETE("handle")
- m_pausedSounds->erase(i);
- unlock();
- return true;
+ if(*i == handle)
+ {
+ delete (*i)->reader; AUD_DELETE("reader")
+ delete *i; AUD_DELETE("handle")
+ m_pausedSounds->erase(i);
+ result = true;
+ break;
+ }
}
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_SoftwareDevice::setKeep(AUD_Handle* handle, bool keep)
{
+ bool result = false;
+
lock();
+
if(isValid(handle))
{
((AUD_SoftwareHandle*)handle)->keep = keep;
- unlock();
- return true;
+ result = true;
}
+
unlock();
- return false;
+
+ return result;
}
bool AUD_SoftwareDevice::sendMessage(AUD_Handle* handle, AUD_Message &message)
@@ -312,16 +336,18 @@ bool AUD_SoftwareDevice::seek(AUD_Handle* handle, float position)
{
lock();
+ bool result = false;
+
if(isValid(handle))
{
AUD_IReader* reader = ((AUD_SoftwareHandle*)handle)->reader;
reader->seek((int)(position * reader->getSpecs().rate));
- unlock();
- return true;
+ result = true;
}
unlock();
- return false;
+
+ return result;
}
float AUD_SoftwareDevice::getPosition(AUD_Handle* handle)
@@ -337,32 +363,41 @@ float AUD_SoftwareDevice::getPosition(AUD_Handle* handle)
}
unlock();
+
return position;
}
AUD_Status AUD_SoftwareDevice::getStatus(AUD_Handle* handle)
{
+ AUD_Status status = AUD_STATUS_INVALID;
+
lock();
+
for(AUD_HandleIterator i = m_playingSounds->begin();
i != m_playingSounds->end(); i++)
{
if(*i == handle)
{
- unlock();
- return AUD_STATUS_PLAYING;
+ status = AUD_STATUS_PLAYING;
+ break;
}
}
- for(AUD_HandleIterator i = m_pausedSounds->begin();
- i != m_pausedSounds->end(); i++)
+ if(status == AUD_STATUS_INVALID)
{
- if(*i == handle)
+ for(AUD_HandleIterator i = m_pausedSounds->begin();
+ i != m_pausedSounds->end(); i++)
{
- unlock();
- return AUD_STATUS_PAUSED;
+ if(*i == handle)
+ {
+ status = AUD_STATUS_PAUSED;
+ break;
+ }
}
}
+
unlock();
- return AUD_STATUS_INVALID;
+
+ return status;
}
void AUD_SoftwareDevice::lock()
@@ -384,6 +419,8 @@ bool AUD_SoftwareDevice::checkCapability(int capability)
bool AUD_SoftwareDevice::setCapability(int capability, void *value)
{
+ bool result = false;
+
switch(capability)
{
case AUD_CAPS_VOLUME:
@@ -407,18 +444,20 @@ bool AUD_SoftwareDevice::setCapability(int capability, void *value)
handle->volume = 1.0;
else if(handle->volume < 0.0)
handle->volume = 0.0;
- unlock();
- return true;
+ result = true;
}
unlock();
}
break;
}
- return false;
+
+ return result;;
}
bool AUD_SoftwareDevice::getCapability(int capability, void *value)
{
+ bool result = false;
+
switch(capability)
{
case AUD_CAPS_VOLUME:
@@ -429,16 +468,19 @@ bool AUD_SoftwareDevice::getCapability(int capability, void *value)
case AUD_CAPS_SOURCE_VOLUME:
{
AUD_SourceCaps* caps = (AUD_SourceCaps*) value;
+
lock();
+
if(isValid(caps->handle))
{
caps->value = ((AUD_SoftwareHandle*)caps->handle)->volume;
- unlock();
- return true;
+ result = true;
}
+
unlock();
}
break;
}
- return false;
+
+ return result;
}
diff --git a/intern/audaspace/make/msvc_9_0/audaspace.vcproj b/intern/audaspace/make/msvc_9_0/audaspace.vcproj
index 0d8ade43e07..93dcdd66628 100644
--- a/intern/audaspace/make/msvc_9_0/audaspace.vcproj
+++ b/intern/audaspace/make/msvc_9_0/audaspace.vcproj
@@ -42,6 +42,7 @@
/>
<Tool
Name="VCCLCompilerTool"
+ Optimization="2"
InlineFunctionExpansion="2"
AdditionalIncludeDirectories="..\..;..\..\ffmpeg;..\..\FX;..\..\intern;..\..\OpenAL;..\..\SDL;..\..\SRC;..\..\sndfile;..\..\..\..\..\lib\windows\pthreads\include;..\..\..\..\..\lib\windows\samplerate\include;..\..\..\..\..\lib\windows\ffmpeg\include;..\..\..\..\..\lib\windows\ffmpeg\include\msvc;..\..\..\..\..\lib\windows\sdl\include;..\..\..\..\..\lib\windows\openal\include;..\..\..\..\..\lib\windows\jack\include;..\..\..\..\..\lib\windows\sndfile\include"
PreprocessorDefinitions="WIN32,NDEBUG,_LIB,WITH_FFMPEG,WITH_SDL,WITH_OPENAL"