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:
authorJoerg Mueller <nexyon@gmail.com>2010-07-28 16:43:59 +0400
committerJoerg Mueller <nexyon@gmail.com>2010-07-28 16:43:59 +0400
commit3ff872bf593f9f4716a21f3be20a13ed136708f2 (patch)
tree637dcb1b1b056840435a598078c47ca72ff5355b /intern/audaspace/OpenAL
parent7296600434c49b40215ba842af73a8b1517e12eb (diff)
Audaspace Refactor:
* Removed whole Capabilities System * Fixed Py API error strings * Improved some Py API properties * Minor other changes
Diffstat (limited to 'intern/audaspace/OpenAL')
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp321
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.h10
2 files changed, 156 insertions, 175 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index 729d4acc077..4d908261ae8 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -27,7 +27,6 @@
#include "AUD_IFactory.h"
#include "AUD_IReader.h"
#include "AUD_ConverterReader.h"
-#include "AUD_SourceCaps.h"
#include <cstring>
#include <limits>
@@ -762,6 +761,20 @@ bool AUD_OpenALDevice::stop(AUD_Handle* handle)
return result;
}
+bool AUD_OpenALDevice::getKeep(AUD_Handle* handle)
+{
+ bool result = false;
+
+ lock();
+
+ if(isValid(handle))
+ result = ((AUD_OpenALHandle*)handle)->keep;
+
+ unlock();
+
+ return result;
+}
+
bool AUD_OpenALDevice::setKeep(AUD_Handle* handle, bool keep)
{
bool result = false;
@@ -910,213 +923,177 @@ void AUD_OpenALDevice::unlock()
pthread_mutex_unlock(&m_mutex);
}
-/******************************************************************************/
-/**************************** Capabilities Code *******************************/
-/******************************************************************************/
+float AUD_OpenALDevice::getVolume() const
+{
+ float result;
+ alGetListenerf(AL_GAIN, &result);
+ return result;
+}
+
+void AUD_OpenALDevice::setVolume(float volume)
+{
+ alListenerf(AL_GAIN, volume);
+}
+
+float AUD_OpenALDevice::getVolume(AUD_Handle* handle)
+{
+ lock();
+ float result = std::numeric_limits<float>::quiet_NaN();
+ if(isValid(handle))
+ alGetSourcef(((AUD_OpenALHandle*)handle)->source,AL_GAIN, &result);
+ unlock();
+ return result;
+}
+
+bool AUD_OpenALDevice::setVolume(AUD_Handle* handle, float volume)
+{
+ lock();
+ bool result = isValid(handle);
+ if(result)
+ alSourcef(((AUD_OpenALHandle*)handle)->source, AL_GAIN, volume);
+ unlock();
+ return result;
+}
+
+float AUD_OpenALDevice::getPitch(AUD_Handle* handle)
+{
+ lock();
+ float result = std::numeric_limits<float>::quiet_NaN();
+ if(isValid(handle))
+ alGetSourcef(((AUD_OpenALHandle*)handle)->source,AL_PITCH, &result);
+ unlock();
+ return result;
+}
-bool AUD_OpenALDevice::checkCapability(int capability)
+bool AUD_OpenALDevice::setPitch(AUD_Handle* handle, float pitch)
{
- return capability == AUD_CAPS_3D_DEVICE ||
- capability == AUD_CAPS_VOLUME ||
- capability == AUD_CAPS_SOURCE_VOLUME ||
- capability == AUD_CAPS_SOURCE_PITCH ||
- capability == AUD_CAPS_BUFFERED_FACTORY;
+ lock();
+ bool result = isValid(handle);
+ if(result)
+ alSourcef(((AUD_OpenALHandle*)handle)->source, AL_PITCH, pitch);
+ unlock();
+ return result;
}
-bool AUD_OpenALDevice::setCapability(int capability, void *value)
+/* AUD_XXX Temorary disabled
+
+bool AUD_OpenALDevice::bufferFactory(void *value)
{
bool result = false;
- switch(capability)
+ AUD_IFactory* factory = (AUD_IFactory*) value;
+
+ // load the factory into an OpenAL buffer
+ if(factory)
{
- case AUD_CAPS_VOLUME:
- alListenerf(AL_GAIN, *((float*)value));
- return true;
- case AUD_CAPS_SOURCE_VOLUME:
- {
- AUD_SourceCaps* caps = (AUD_SourceCaps*) value;
- lock();
- if(isValid(caps->handle))
- {
- alSourcef(((AUD_OpenALHandle*)caps->handle)->source,
- AL_GAIN, caps->value);
- result = true;
- }
- unlock();
- }
- break;
- case AUD_CAPS_SOURCE_PITCH:
+ // check if the factory is already buffered
+ lock();
+ for(AUD_BFIterator i = m_bufferedFactories->begin();
+ i != m_bufferedFactories->end(); i++)
{
- AUD_SourceCaps* caps = (AUD_SourceCaps*) value;
- lock();
- if(isValid(caps->handle))
+ if((*i)->factory == factory)
{
- alSourcef(((AUD_OpenALHandle*)caps->handle)->source,
- AL_PITCH, caps->value);
result = true;
+ break;
}
- unlock();
}
- break;
- case AUD_CAPS_BUFFERED_FACTORY:
- {
- AUD_IFactory* factory = (AUD_IFactory*) value;
-
- // load the factory into an OpenAL buffer
- if(factory)
- {
- // check if the factory is already buffered
- lock();
- for(AUD_BFIterator i = m_bufferedFactories->begin();
- i != m_bufferedFactories->end(); i++)
- {
- if((*i)->factory == factory)
- {
- result = true;
- break;
- }
- }
- unlock();
- if(result)
- return result;
-
- AUD_IReader* reader = factory->createReader();
-
- if(reader == NULL)
- return false;
+ unlock();
+ if(result)
+ return result;
- AUD_DeviceSpecs specs = m_specs;
- specs.specs = reader->getSpecs();
+ AUD_IReader* reader = factory->createReader();
- if(m_specs.format != AUD_FORMAT_FLOAT32)
- reader = new AUD_ConverterReader(reader, m_specs);
+ if(reader == NULL)
+ return false;
- ALenum format;
+ AUD_DeviceSpecs specs = m_specs;
+ specs.specs = reader->getSpecs();
- if(!getFormat(format, specs.specs))
- {
- delete reader;
- return false;
- }
+ if(m_specs.format != AUD_FORMAT_FLOAT32)
+ reader = new AUD_ConverterReader(reader, m_specs);
- // load into a buffer
- lock();
- alcSuspendContext(m_context);
+ ALenum format;
- AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory;
- bf->factory = factory;
+ if(!getFormat(format, specs.specs))
+ {
+ delete reader;
+ return false;
+ }
- try
- {
- alGenBuffers(1, &bf->buffer);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL);
+ // load into a buffer
+ lock();
+ alcSuspendContext(m_context);
- try
- {
- sample_t* buf;
- int length = reader->getLength();
+ AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory;
+ bf->factory = factory;
- reader->read(length, buf);
- alBufferData(bf->buffer, format, buf,
- length * AUD_DEVICE_SAMPLE_SIZE(specs),
- specs.rate);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL);
- }
- catch(AUD_Exception&)
- {
- alDeleteBuffers(1, &bf->buffer);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- delete bf;
- delete reader;
- alcProcessContext(m_context);
- unlock();
- return false;
- }
+ try
+ {
+ alGenBuffers(1, &bf->buffer);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(AUD_ERROR_OPENAL);
- m_bufferedFactories->push_back(bf);
+ try
+ {
+ sample_t* buf;
+ int length = reader->getLength();
- alcProcessContext(m_context);
- unlock();
+ reader->read(length, buf);
+ alBufferData(bf->buffer, format, buf,
+ length * AUD_DEVICE_SAMPLE_SIZE(specs),
+ specs.rate);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(AUD_ERROR_OPENAL);
}
- else
+ catch(AUD_Exception&)
{
- // stop all playing and paused buffered sources
- lock();
- alcSuspendContext(m_context);
-
- AUD_OpenALHandle* sound;
- AUD_HandleIterator it = m_playingSounds->begin();
- while(it != m_playingSounds->end())
- {
- sound = *it;
- ++it;
-
- if(sound->isBuffered)
- stop(sound);
- }
- alcProcessContext(m_context);
-
- while(!m_bufferedFactories->empty())
- {
- alDeleteBuffers(1,
- &(*(m_bufferedFactories->begin()))->buffer);
- delete *m_bufferedFactories->begin();
- m_bufferedFactories->erase(m_bufferedFactories->begin());
- }
- unlock();
+ alDeleteBuffers(1, &bf->buffer);
+ throw;
}
-
- return true;
}
- break;
- }
- return result;
-}
+ catch(AUD_Exception&)
+ {
+ delete bf;
+ delete reader;
+ alcProcessContext(m_context);
+ unlock();
+ return false;
+ }
-bool AUD_OpenALDevice::getCapability(int capability, void *value)
-{
- bool result = false;
+ m_bufferedFactories->push_back(bf);
- switch(capability)
+ alcProcessContext(m_context);
+ unlock();
+ }
+ else
{
- case AUD_CAPS_VOLUME:
- alGetListenerf(AL_GAIN, (float*)value);
- return true;
- case AUD_CAPS_SOURCE_VOLUME:
+ // stop all playing and paused buffered sources
+ lock();
+ alcSuspendContext(m_context);
+
+ AUD_OpenALHandle* sound;
+ AUD_HandleIterator it = m_playingSounds->begin();
+ while(it != m_playingSounds->end())
{
- AUD_SourceCaps* caps = (AUD_SourceCaps*) value;
- lock();
- if(isValid(caps->handle))
- {
- alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source,
- AL_GAIN, &caps->value);
- result = true;
- }
- unlock();
+ sound = *it;
+ ++it;
+
+ if(sound->isBuffered)
+ stop(sound);
}
- break;
- case AUD_CAPS_SOURCE_PITCH:
+ alcProcessContext(m_context);
+
+ while(!m_bufferedFactories->empty())
{
- AUD_SourceCaps* caps = (AUD_SourceCaps*) value;
- lock();
- if(isValid(caps->handle))
- {
- alGetSourcef(((AUD_OpenALHandle*)caps->handle)->source,
- AL_PITCH, &caps->value);
- result = true;
- }
- unlock();
+ alDeleteBuffers(1,
+ &(*(m_bufferedFactories->begin()))->buffer);
+ delete *m_bufferedFactories->begin();
+ m_bufferedFactories->erase(m_bufferedFactories->begin());
}
- break;
+ unlock();
}
- return result;
-}
+ return true;
+}*/
/******************************************************************************/
/**************************** 3D Device Code **********************************/
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
index c36f89209d3..fa8f7c55134 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
@@ -145,15 +145,19 @@ public:
virtual bool pause(AUD_Handle* handle);
virtual bool resume(AUD_Handle* handle);
virtual bool stop(AUD_Handle* handle);
+ virtual bool getKeep(AUD_Handle* handle);
virtual bool setKeep(AUD_Handle* handle, bool keep);
virtual bool seek(AUD_Handle* handle, float position);
virtual float getPosition(AUD_Handle* handle);
virtual AUD_Status getStatus(AUD_Handle* handle);
virtual void lock();
virtual void unlock();
- virtual bool checkCapability(int capability);
- virtual bool setCapability(int capability, void *value);
- virtual bool getCapability(int capability, void *value);
+ virtual float getVolume() const;
+ virtual void setVolume(float volume);
+ virtual float getVolume(AUD_Handle* handle);
+ virtual bool setVolume(AUD_Handle* handle, float volume);
+ virtual float getPitch(AUD_Handle* handle);
+ virtual bool setPitch(AUD_Handle* handle, float pitch);
virtual AUD_Handle* play3D(AUD_IFactory* factory, bool keep = false);
virtual bool updateListener(AUD_3DData &data);