[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30921] branches/soc-2010-nexyon: Audaspace:
Joerg Mueller
nexyon at gmail.com
Sat Jul 31 12:03:09 CEST 2010
Revision: 30921
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30921
Author: nexyon
Date: 2010-07-31 12:03:08 +0200 (Sat, 31 Jul 2010)
Log Message:
-----------
Audaspace:
* Fixed some compiler warnings
* Implemented device looping
* Note: Scrubbing in the sequencer is broken atm
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_C-API.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/source/blender/blenkernel/intern/sound.c
branches/soc-2010-nexyon/source/gameengine/Ketsji/KX_SoundActuator.cpp
Modified: branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp 2010-07-31 10:03:08 UTC (rev 30921)
@@ -65,6 +65,9 @@
/// 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 @@
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 @@
sound->current = -1;
sound->isBuffered = true;
sound->data_end = true;
+ sound->loopcount = 0;
alcSuspendContext(m_context);
@@ -578,6 +594,7 @@
sound->current = 0;
sound->isBuffered = false;
sound->data_end = false;
+ sound->loopcount = 0;
valid &= getFormat(sound->format, specs.specs);
@@ -975,6 +992,26 @@
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)
Modified: branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.h 2010-07-31 10:03:08 UTC (rev 30921)
@@ -158,6 +158,8 @@
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);
Modified: branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp 2010-07-31 10:03:08 UTC (rev 30921)
@@ -1228,8 +1228,7 @@
try
{
- // AUD_XXX will come soon; return Py_BuildValue("f", device->device->getPitch(self->handle));
- AUD_THROW(AUD_ERROR_FACTORY);
+ return Py_BuildValue("i", device->device->getLoopCount(self->handle));
}
catch(AUD_Exception&)
{
@@ -1250,14 +1249,8 @@
try
{
- /* AUD_XXX Doesn't work atm, will come back
- AUD_Message message;
- message.loopcount = loops;
- message.type = AUD_MSG_LOOP;
- if(device->device->sendMessage(self->handle, message))
- {
+ if(device->device->setLoopCount(self->handle, loops))
return 0;
- }*/
}
catch(AUD_Exception&)
{
@@ -1302,7 +1295,7 @@
float x, y, z;
if(!PyArg_Parse(args, "(fff)", &x, &y, &z))
- return NULL;
+ return -1;
Device* dev = (Device*)self->device;
@@ -1361,7 +1354,7 @@
float x, y, z;
if(!PyArg_Parse(args, "(fff)", &x, &y, &z))
- return NULL;
+ return -1;
Device* dev = (Device*)self->device;
@@ -1420,7 +1413,7 @@
float w, x, y, z;
if(!PyArg_Parse(args, "(ffff)", &w, &x, &y, &z))
- return NULL;
+ return -1;
Device* dev = (Device*)self->device;
@@ -2368,7 +2361,7 @@
float x, y, z;
if(!PyArg_Parse(args, "(fff)", &x, &y, &z))
- return NULL;
+ return -1;
try
{
@@ -2423,7 +2416,7 @@
float x, y, z;
if(!PyArg_Parse(args, "(fff)", &x, &y, &z))
- return NULL;
+ return -1;
try
{
@@ -2478,7 +2471,7 @@
float w, x, y, z;
if(!PyArg_Parse(args, "(ffff)", &w, &x, &y, &z))
- return NULL;
+ return -1;
try
{
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.cpp 2010-07-31 10:03:08 UTC (rev 30921)
@@ -344,24 +344,17 @@
}
}
-int AUD_setLoop(AUD_Channel* handle, int loops, float time)
+int AUD_setLoop(AUD_Channel* handle, int loops)
{
if(handle)
{
- /* AUD_XXX Doesn't work atm, will come back
-
- AUD_Message message;
- message.type = AUD_MSG_LOOP;
- message.loopcount = loops;
- message.time = time;
-
try
{
- return AUD_device->sendMessage(handle, message);
+ return AUD_device->setLoopCount(handle, loops);
}
catch(AUD_Exception&)
{
- }*/
+ }
}
return false;
}
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.h 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_C-API.h 2010-07-31 10:03:08 UTC (rev 30921)
@@ -165,10 +165,9 @@
* Sets a remaining loop count of a looping sound that currently plays.
* \param handle The playback handle.
* \param loops The count of remaining loops, -1 for infinity.
- * \param time The time after which playback should stop, -1 for infinity.
* \return Whether the handle is valid.
*/
-extern int AUD_setLoop(AUD_Channel* handle, int loops, float time);
+extern int AUD_setLoop(AUD_Channel* handle, int loops);
/**
* Rectifies a sound.
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IDevice.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IDevice.h 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_IDevice.h 2010-07-31 10:03:08 UTC (rev 30921)
@@ -207,6 +207,24 @@
* - false if the handle is invalid.
*/
virtual bool setPitch(AUD_Handle* handle, float pitch)=0;
+
+ /**
+ * Retrieves the loop count of a playing sound.
+ * A negative value indicates infinity.
+ * \return The remaining loop count.
+ */
+ virtual int getLoopCount(AUD_Handle* handle)=0;
+
+ /**
+ * Sets the loop count of a playing sound.
+ * A negative value indicates infinity.
+ * \param handle The sound handle.
+ * \param count The new loop count.
+ * \return
+ * - true if the handle is valid.
+ * - false if the handle is invalid.
+ */
+ virtual bool setLoopCount(AUD_Handle* handle, int count)=0;
};
#endif //AUD_IDevice
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.cpp 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.cpp 2010-07-31 10:03:08 UTC (rev 30921)
@@ -123,3 +123,13 @@
{
return false;
}
+
+int AUD_NULLDevice::getLoopCount(AUD_Handle* handle)
+{
+ return 0;
+}
+
+bool AUD_NULLDevice::setLoopCount(AUD_Handle* handle, int count)
+{
+ return false;
+}
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.h
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.h 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_NULLDevice.h 2010-07-31 10:03:08 UTC (rev 30921)
@@ -57,6 +57,8 @@
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);
};
#endif //AUD_NULLDEVICE
Modified: branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.cpp 2010-07-31 08:03:25 UTC (rev 30920)
+++ branches/soc-2010-nexyon/intern/audaspace/intern/AUD_SoftwareDevice.cpp 2010-07-31 10:03:08 UTC (rev 30921)
@@ -42,14 +42,15 @@
/// The volume of the source.
float volume;
+
+ /// The loop count of the source.
+ int loopcount;
};
typedef std::list<AUD_SoftwareHandle*>::iterator AUD_HandleIterator;
void AUD_SoftwareDevice::create()
{
- m_playingSounds = new std::list<AUD_SoftwareHandle*>();
- m_pausedSounds = new std::list<AUD_SoftwareHandle*>();
m_playback = false;
m_volume = 1.0f;
m_mixer = new AUD_DefaultMixer(m_specs);
@@ -70,23 +71,25 @@
delete m_mixer;
+ AUD_SoftwareHandle* handle;
+
// delete all playing sounds
- while(m_playingSounds->begin() != m_playingSounds->end())
+ while(!m_playingSounds.empty())
{
- delete (*(m_playingSounds->begin()))->reader;
- delete *(m_playingSounds->begin());
- m_playingSounds->erase(m_playingSounds->begin());
+ handle = m_playingSounds.front();
+ m_playingSounds.pop_front();
+ delete handle->reader;
+ delete handle;
}
- delete m_playingSounds;
// delete all paused sounds
- while(m_pausedSounds->begin() != m_pausedSounds->end())
+ while(!m_pausedSounds.empty())
{
- delete (*(m_pausedSounds->begin()))->reader;
- delete *(m_pausedSounds->begin());
- m_pausedSounds->erase(m_pausedSounds->begin());
+ handle = m_pausedSounds.front();
+ m_pausedSounds.pop_front();
+ delete handle->reader;
+ delete handle;
}
- delete m_pausedSounds;
pthread_mutex_destroy(&m_mutex);
}
@@ -98,12 +101,16 @@
{
AUD_SoftwareHandle* sound;
int len;
+ int pos;
sample_t* buf;
std::list<AUD_SoftwareHandle*> stopSounds;
+ std::list<AUD_Buffer*> tempBufs;
+ AUD_Buffer* tempbuf;
+ int samplesize = AUD_SAMPLE_SIZE(m_specs);
// for all sounds
- AUD_HandleIterator it = m_playingSounds->begin();
- while(it != m_playingSounds->end())
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list