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>2011-02-19 02:50:27 +0300
committerJoerg Mueller <nexyon@gmail.com>2011-02-19 02:50:27 +0300
commitd36a89c8f41f455895b6e52ce798c36c9debb967 (patch)
tree3c704d52e2273c96d954c2882c3f9f25a694e55f /intern/audaspace/OpenAL
parent020c03bc05e05a57d6a9947834788777f038edc1 (diff)
Audaspace:
* Adding play method to the device classes to play back a reader (not used yet, preparation for a later feature). * Using a linear resampler in case SRC is disabled.
Diffstat (limited to 'intern/audaspace/OpenAL')
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp149
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.h1
2 files changed, 78 insertions, 72 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index 2873b68ce47..94cac65d1fb 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -534,81 +534,10 @@ static const char* queue_error = "AUD_OpenALDevice: Buffer couldn't be "
static const char* bufferdata_error = "AUD_OpenALDevice: Buffer couldn't be "
"filled with data.";
-AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
+AUD_Handle* AUD_OpenALDevice::play(AUD_IReader* reader, bool keep)
{
- lock();
-
AUD_OpenALHandle* sound = NULL;
- try
- {
- // 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
- sound = new AUD_OpenALHandle;
- sound->keep = keep;
- sound->current = -1;
- sound->isBuffered = true;
- sound->data_end = true;
- sound->loopcount = 0;
- sound->stop = NULL;
- sound->stop_data = NULL;
-
- alcSuspendContext(m_context);
-
- // OpenAL playback code
- try
- {
- alGenSources(1, &sound->source);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
-
- try
- {
- alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
- if(alGetError() != AL_NO_ERROR)
- AUD_THROW(AUD_ERROR_OPENAL, queue_error);
- }
- catch(AUD_Exception&)
- {
- alDeleteSources(1, &sound->source);
- throw;
- }
- }
- catch(AUD_Exception&)
- {
- delete sound;
- alcProcessContext(m_context);
- throw;
- }
-
- // play sound
- m_playingSounds->push_back(sound);
-
- alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
- start();
-
- alcProcessContext(m_context);
- }
- }
- }
- catch(AUD_Exception&)
- {
- unlock();
- throw;
- }
-
- unlock();
-
- if(sound)
- return sound;
-
- AUD_IReader* reader = factory->createReader();
-
AUD_DeviceSpecs specs = m_specs;
specs.specs = reader->getSpecs();
@@ -708,6 +637,82 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
return sound;
}
+AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
+{
+ AUD_OpenALHandle* sound = NULL;
+
+ lock();
+
+ try
+ {
+ // 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
+ sound = new AUD_OpenALHandle;
+ sound->keep = keep;
+ sound->current = -1;
+ sound->isBuffered = true;
+ sound->data_end = true;
+ sound->loopcount = 0;
+ sound->stop = NULL;
+ sound->stop_data = NULL;
+
+ alcSuspendContext(m_context);
+
+ // OpenAL playback code
+ try
+ {
+ alGenSources(1, &sound->source);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
+
+ try
+ {
+ alSourcei(sound->source, AL_BUFFER, (*i)->buffer);
+ if(alGetError() != AL_NO_ERROR)
+ AUD_THROW(AUD_ERROR_OPENAL, queue_error);
+ }
+ catch(AUD_Exception&)
+ {
+ alDeleteSources(1, &sound->source);
+ throw;
+ }
+ }
+ catch(AUD_Exception&)
+ {
+ delete sound;
+ alcProcessContext(m_context);
+ throw;
+ }
+
+ // play sound
+ m_playingSounds->push_back(sound);
+
+ alSourcei(sound->source, AL_SOURCE_RELATIVE, 1);
+ start();
+
+ alcProcessContext(m_context);
+ }
+ }
+ }
+ catch(AUD_Exception&)
+ {
+ unlock();
+ throw;
+ }
+
+ unlock();
+
+ if(sound)
+ return sound;
+
+ return play(factory->createReader(), keep);
+}
+
bool AUD_OpenALDevice::pause(AUD_Handle* handle)
{
bool result = false;
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
index e997c9df5ad..3965ff03533 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
@@ -142,6 +142,7 @@ public:
virtual ~AUD_OpenALDevice();
virtual AUD_DeviceSpecs getSpecs() const;
+ virtual AUD_Handle* play(AUD_IReader* reader, bool keep = false);
virtual AUD_Handle* play(AUD_IFactory* factory, bool keep = false);
virtual bool pause(AUD_Handle* handle);
virtual bool resume(AUD_Handle* handle);