Revision: 30837 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30837 Author: nexyon Date: 2010-07-28 14:43:59 +0200 (Wed, 28 Jul 2010)
Log Message: ----------- Audaspace Refactor: * Removed whole Capabilities System * Fixed Py API error strings * Improved some Py API properties * Minor other changes Modified Paths: -------------- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_FileFactory.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_I3DDevice.h branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IDevice.h branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.h branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.cpp branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.h branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Space.h Removed Paths: ------------- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SourceCaps.h Modified: branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp =================================================================== --- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp 2010-07-28 12:31:31 UTC (rev 30836) +++ branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp 2010-07-28 12:43:59 UTC (rev 30837) @@ -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 @@ 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 @@ pthread_mutex_unlock(&m_mutex); } -/******************************************************************************/ -/**************************** Capabilities Code *******************************/ -/******************************************************************************/ +float AUD_OpenALDevice::getVolume() const +{ + float result; + alGetListenerf(AL_GAIN, &result); + return result; +} -bool AUD_OpenALDevice::checkCapability(int capability) +void AUD_OpenALDevice::setVolume(float volume) { - 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; + alListenerf(AL_GAIN, volume); } -bool AUD_OpenALDevice::setCapability(int capability, void *value) +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::setPitch(AUD_Handle* handle, float pitch) +{ + lock(); + bool result = isValid(handle); + if(result) + alSourcef(((AUD_OpenALHandle*)handle)->source, AL_PITCH, pitch); + unlock(); + return result; +} + +/* 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: + // 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_GAIN, caps->value); result = true; + break; } - unlock(); } - break; - case AUD_CAPS_SOURCE_PITCH: - { - AUD_SourceCaps* caps = (AUD_SourceCaps*) value; - lock(); - if(isValid(caps->handle)) - { - alSourcef(((AUD_OpenALHandle*)caps->handle)->source, - AL_PITCH, caps->value); - result = true; - } - unlock(); - } - break; - case AUD_CAPS_BUFFERED_FACTORY: - { - AUD_IFactory* factory = (AUD_IFactory*) value; + unlock(); + if(result) + return result; - // 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(); - AUD_IReader* reader = factory->createReader(); + if(reader == NULL) + return false; - if(reader == NULL) - return false; + AUD_DeviceSpecs specs = m_specs; + specs.specs = reader->getSpecs(); - AUD_DeviceSpecs specs = m_specs; - specs.specs = reader->getSpecs(); + if(m_specs.format != AUD_FORMAT_FLOAT32) + reader = new AUD_ConverterReader(reader, m_specs); - if(m_specs.format != AUD_FORMAT_FLOAT32) - reader = new AUD_ConverterReader(reader, m_specs); + ALenum format; - ALenum format; + if(!getFormat(format, specs.specs)) + { + delete reader; + return false; + } - if(!getFormat(format, specs.specs)) - { - delete reader; - return false; - } + // load into a buffer + lock(); + alcSuspendContext(m_context); - // load into a buffer - lock(); - alcSuspendContext(m_context); + AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory; + bf->factory = factory; - AUD_OpenALBufferedFactory* bf = new AUD_OpenALBufferedFactory; - bf->factory = factory; + try + { + alGenBuffers(1, &bf->buffer); + if(alGetError() != AL_NO_ERROR) + AUD_THROW(AUD_ERROR_OPENAL); - try - { - alGenBuffers(1, &bf->buffer); - if(alGetError() != AL_NO_ERROR) - AUD_THROW(AUD_ERROR_OPENAL); + try + { + sample_t* buf; + int length = reader->getLength(); - try - { - sample_t* buf; - int length = reader->getLength(); - - 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; - } - - m_bufferedFactories->push_back(bf); - - 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 **********************************/ Modified: branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h =================================================================== --- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h 2010-07-28 12:31:31 UTC (rev 30836) +++ branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h 2010-07-28 12:43:59 UTC (rev 30837) @@ -145,15 +145,19 @@ 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); Modified: branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs