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-31 14:03:08 +0400
committerJoerg Mueller <nexyon@gmail.com>2010-07-31 14:03:08 +0400
commit5c9cf81cf98c99e52064b0cd45be3b2eaba9e40c (patch)
tree463240a84d34a3debf5bba9c326827fb436db703 /intern/audaspace/OpenAL
parent61c9e46aad2cf679331341c7d38f10bec19203a9 (diff)
Audaspace:
* Fixed some compiler warnings * Implemented device looping * Note: Scrubbing in the sequencer is broken atm
Diffstat (limited to 'intern/audaspace/OpenAL')
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.cpp37
-rw-r--r--intern/audaspace/OpenAL/AUD_OpenALDevice.h2
2 files changed, 39 insertions, 0 deletions
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
index 6d1f9a5527b..88e48ff20ba 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
@@ -65,6 +65,9 @@ struct AUD_OpenALHandle : AUD_Handle
/// Whether the stream doesn't return any more data.
bool data_end;
+
+ /// The loop count of the source.
+ int loopcount;
};
struct AUD_OpenALBufferedFactory
@@ -156,6 +159,18 @@ void AUD_OpenALDevice::updateStreams()
length = m_buffersize;
sound->reader->read(length, buffer);
+ // looping necessary?
+ if(length == 0 && sound->loopcount)
+ {
+ if(sound->loopcount > 0)
+ sound->loopcount--;
+
+ sound->reader->seek(0);
+
+ length = m_buffersize;
+ sound->reader->read(length, buffer);
+ }
+
// read nothing?
if(length == 0)
{
@@ -507,6 +522,7 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
sound->current = -1;
sound->isBuffered = true;
sound->data_end = true;
+ sound->loopcount = 0;
alcSuspendContext(m_context);
@@ -578,6 +594,7 @@ AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
sound->current = 0;
sound->isBuffered = false;
sound->data_end = false;
+ sound->loopcount = 0;
valid &= getFormat(sound->format, specs.specs);
@@ -975,6 +992,26 @@ bool AUD_OpenALDevice::setPitch(AUD_Handle* handle, float pitch)
return result;
}
+int AUD_OpenALDevice::getLoopCount(AUD_Handle* handle)
+{
+ lock();
+ int result = 0;
+ if(isValid(handle))
+ result = ((AUD_OpenALHandle*)handle)->loopcount;
+ unlock();
+ return result;
+}
+
+bool AUD_OpenALDevice::setLoopCount(AUD_Handle* handle, int count)
+{
+ lock();
+ bool result = isValid(handle);
+ if(result)
+ ((AUD_OpenALHandle*)handle)->loopcount = count;
+ unlock();
+ return result;
+}
+
/* AUD_XXX Temorary disabled
bool AUD_OpenALDevice::bufferFactory(void *value)
diff --git a/intern/audaspace/OpenAL/AUD_OpenALDevice.h b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
index cba031f25f9..37a5b886882 100644
--- a/intern/audaspace/OpenAL/AUD_OpenALDevice.h
+++ b/intern/audaspace/OpenAL/AUD_OpenALDevice.h
@@ -158,6 +158,8 @@ public:
virtual bool setVolume(AUD_Handle* handle, float volume);
virtual float getPitch(AUD_Handle* handle);
virtual bool setPitch(AUD_Handle* handle, float pitch);
+ virtual int getLoopCount(AUD_Handle* handle);
+ virtual bool setLoopCount(AUD_Handle* handle, int count);
virtual AUD_Vector3 getListenerLocation() const;
virtual void setListenerLocation(const AUD_Vector3& location);