From 5c9cf81cf98c99e52064b0cd45be3b2eaba9e40c Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 31 Jul 2010 10:03:08 +0000 Subject: Audaspace: * Fixed some compiler warnings * Implemented device looping * Note: Scrubbing in the sequencer is broken atm --- intern/audaspace/OpenAL/AUD_OpenALDevice.cpp | 37 ++++++++++++++++++++++++++++ intern/audaspace/OpenAL/AUD_OpenALDevice.h | 2 ++ 2 files changed, 39 insertions(+) (limited to 'intern/audaspace/OpenAL') 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); -- cgit v1.2.3