[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31002] branches/soc-2010-nexyon/intern/ audaspace: Audaspace:

Joerg Mueller nexyon at gmail.com
Tue Aug 3 10:07:21 CEST 2010


Revision: 31002
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31002
Author:   nexyon
Date:     2010-08-03 10:07:21 +0200 (Tue, 03 Aug 2010)

Log Message:
-----------
Audaspace:
* Added an error string for audaspace exceptions.
* Fixed PyAPI exceptions.
* Minor bugfixes.
* Added a name parameter to the Jack device, so that one can define an own name via Python.

Modified Paths:
--------------
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
    branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp
    branches/soc-2010-nexyon/intern/audaspace/SDL/AUD_SDLDevice.cpp
    branches/soc-2010-nexyon/intern/audaspace/SRC/AUD_SRCResampleReader.cpp
    branches/soc-2010-nexyon/intern/audaspace/ffmpeg/AUD_FFMPEGReader.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_SoftwareDevice.cpp
    branches/soc-2010-nexyon/intern/audaspace/intern/AUD_Space.h
    branches/soc-2010-nexyon/intern/audaspace/jack/AUD_JackDevice.cpp
    branches/soc-2010-nexyon/intern/audaspace/jack/AUD_JackDevice.h
    branches/soc-2010-nexyon/intern/audaspace/sndfile/AUD_SndFileReader.cpp

Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.cpp	2010-08-03 06:51:36 UTC (rev 31001)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_DoubleReader.cpp	2010-08-03 08:07:21 UTC (rev 31002)
@@ -27,6 +27,9 @@
 
 #include <cstring>
 
+static const char* specs_error = "AUD_DoubleReader: Both readers have to have "
+								 "the same specs.";
+
 AUD_DoubleReader::AUD_DoubleReader(AUD_IReader* reader1,
 								   AUD_IReader* reader2) :
 		m_reader1(reader1), m_reader2(reader2), m_finished1(false)
@@ -38,7 +41,7 @@
 	{
 		delete reader1;
 		delete reader2;
-		AUD_THROW(AUD_ERROR_READER);
+		AUD_THROW(AUD_ERROR_SPECS, specs_error);
 	}
 }
 

Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.cpp	2010-08-03 06:51:36 UTC (rev 31001)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_ReverseReader.cpp	2010-08-03 08:07:21 UTC (rev 31002)
@@ -27,13 +27,16 @@
 
 #include <cstring>
 
+static const char* props_error = "AUD_ReverseReader: The reader has to be "
+								 "seekable and a finite length.";
+
 AUD_ReverseReader::AUD_ReverseReader(AUD_IReader* reader) :
 		AUD_EffectReader(reader),
 		m_length(reader->getLength()),
 		m_position(0)
 {
 	if(m_length < 0 || !reader->isSeekable())
-		AUD_THROW(AUD_ERROR_READER);
+		AUD_THROW(AUD_ERROR_PROPS, props_error);
 }
 
 void AUD_ReverseReader::seek(int position)

Modified: branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.cpp	2010-08-03 06:51:36 UTC (rev 31001)
+++ branches/soc-2010-nexyon/intern/audaspace/FX/AUD_SuperposeReader.cpp	2010-08-03 08:07:21 UTC (rev 31002)
@@ -27,6 +27,9 @@
 
 #include <cstring>
 
+static const char* specs_error = "AUD_SuperposeReader: Both readers have to "
+								 "have the same specs.";
+
 AUD_SuperposeReader::AUD_SuperposeReader(AUD_IReader* reader1, AUD_IReader* reader2) :
 	m_reader1(reader1), m_reader2(reader2)
 {
@@ -36,7 +39,7 @@
 		s1 = reader1->getSpecs();
 		s2 = reader2->getSpecs();
 		if(memcmp(&s1, &s2, sizeof(AUD_Specs)))
-			AUD_THROW(AUD_ERROR_READER);
+			AUD_THROW(AUD_ERROR_SPECS, specs_error);
 	}
 	catch(AUD_Exception&)
 	{

Modified: branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp	2010-08-03 06:51:36 UTC (rev 31001)
+++ branches/soc-2010-nexyon/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp	2010-08-03 08:07:21 UTC (rev 31002)
@@ -289,6 +289,8 @@
 	return false;
 }
 
+static const char* open_error = "AUD_OpenALDevice: Device couldn't be opened.";
+
 AUD_OpenALDevice::AUD_OpenALDevice(AUD_DeviceSpecs specs, int buffersize)
 {
 	// cannot determine how many channels or which format OpenAL uses, but
@@ -313,7 +315,7 @@
 	m_device = alcOpenDevice(NULL);
 
 	if(!m_device)
-		AUD_THROW(AUD_ERROR_OPENAL);
+		AUD_THROW(AUD_ERROR_OPENAL, open_error);
 
 	// at least try to set the frequency
 	ALCint attribs[] = { ALC_FREQUENCY, specs.rate, 0 };
@@ -513,6 +515,15 @@
 	return valid;
 }
 
+static const char* genbuffer_error = "AUD_OpenALDevice: Buffer couldn't be "
+									 "generated.";
+static const char* gensource_error = "AUD_OpenALDevice: Source couldn't be "
+									 "generated.";
+static const char* queue_error = "AUD_OpenALDevice: Buffer couldn't be "
+								 "queued to the source.";
+static const char* bufferdata_error = "AUD_OpenALDevice: Buffer couldn't be "
+									  "filled with data.";
+
 AUD_Handle* AUD_OpenALDevice::play(AUD_IFactory* factory, bool keep)
 {
 	lock();
@@ -542,13 +553,13 @@
 				{
 					alGenSources(1, &sound->source);
 					if(alGetError() != AL_NO_ERROR)
-						AUD_THROW(AUD_ERROR_OPENAL);
+						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);
+							AUD_THROW(AUD_ERROR_OPENAL, queue_error);
 					}
 					catch(AUD_Exception&)
 					{
@@ -586,9 +597,6 @@
 
 	AUD_IReader* reader = factory->createReader();
 
-	if(reader == NULL)
-		AUD_THROW(AUD_ERROR_READER);
-
 	AUD_DeviceSpecs specs = m_specs;
 	specs.specs = reader->getSpecs();
 
@@ -624,7 +632,7 @@
 	{
 		alGenBuffers(AUD_OPENAL_CYCLE_BUFFERS, sound->buffers);
 		if(alGetError() != AL_NO_ERROR)
-			AUD_THROW(AUD_ERROR_OPENAL);
+			AUD_THROW(AUD_ERROR_OPENAL, genbuffer_error);
 
 		try
 		{
@@ -639,19 +647,19 @@
 							 length * AUD_DEVICE_SAMPLE_SIZE(specs),
 							 specs.rate);
 				if(alGetError() != AL_NO_ERROR)
-					AUD_THROW(AUD_ERROR_OPENAL);
+					AUD_THROW(AUD_ERROR_OPENAL, bufferdata_error);
 			}
 
 			alGenSources(1, &sound->source);
 			if(alGetError() != AL_NO_ERROR)
-				AUD_THROW(AUD_ERROR_OPENAL);
+				AUD_THROW(AUD_ERROR_OPENAL, gensource_error);
 
 			try
 			{
 				alSourceQueueBuffers(sound->source, AUD_OPENAL_CYCLE_BUFFERS,
 									 sound->buffers);
 				if(alGetError() != AL_NO_ERROR)
-					AUD_THROW(AUD_ERROR_OPENAL);
+					AUD_THROW(AUD_ERROR_OPENAL, queue_error);
 			}
 			catch(AUD_Exception&)
 			{

Modified: branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp
===================================================================
--- branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp	2010-08-03 06:51:36 UTC (rev 31001)
+++ branches/soc-2010-nexyon/intern/audaspace/Python/AUD_PyAPI.cpp	2010-08-03 08:07:21 UTC (rev 31002)
@@ -80,6 +80,8 @@
 
 static PyObject* AUDError;
 
+static const char* device_not_3d_error = "Device is not a 3D device!";
+
 // ====================================================================
 
 static void
@@ -102,26 +104,20 @@
 		static const char *kwlist[] = {"filename", NULL};
 		const char* filename = NULL;
 
-		if(!PyArg_ParseTupleAndKeywords(args, kwds, "|s", const_cast<char**>(kwlist), &filename))
+		if(!PyArg_ParseTupleAndKeywords(args, kwds, "s:Sound", const_cast<char**>(kwlist), &filename))
 		{
 			Py_DECREF(self);
 			return NULL;
 		}
-		else if(filename == NULL)
-		{
-			Py_DECREF(self);
-			PyErr_SetString(AUDError, "Missing filename parameter!");
-			return NULL;
-		}
 
 		try
 		{
 			self->factory = new AUD_FileFactory(filename);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(self);
-			PyErr_SetString(AUDError, "Filefactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -460,7 +456,7 @@
 	float frequency;
 	int rate = 44100;
 
-	if(!PyArg_ParseTuple(args, "f|i", &frequency, &rate))
+	if(!PyArg_ParseTuple(args, "f|i:sine", &frequency, &rate))
 		return NULL;
 
 	Sound *self;
@@ -472,10 +468,10 @@
 		{
 			self->factory = new AUD_SinusFactory(frequency, (AUD_SampleRate)rate);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(self);
-			PyErr_SetString(AUDError, "Sinusfactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -488,7 +484,7 @@
 {
 	const char* filename = NULL;
 
-	if(!PyArg_ParseTuple(args, "s", &filename))
+	if(!PyArg_ParseTuple(args, "s:file", &filename))
 		return NULL;
 
 	Sound *self;
@@ -500,10 +496,10 @@
 		{
 			self->factory = new AUD_FileFactory(filename);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(self);
-			PyErr_SetString(AUDError, "Filefactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -517,7 +513,7 @@
 	float frequency;
 	float Q = 0.5;
 
-	if(!PyArg_ParseTuple(args, "f|f", &frequency, &Q))
+	if(!PyArg_ParseTuple(args, "f|f:lowpass", &frequency, &Q))
 		return NULL;
 
 	Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0);
@@ -531,10 +527,10 @@
 		{
 			parent->factory = new AUD_LowpassFactory(self->factory, frequency, Q);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(parent);
-			PyErr_SetString(AUDError, "Lowpassfactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -547,7 +543,7 @@
 {
 	float delay;
 
-	if(!PyArg_ParseTuple(args, "f", &delay))
+	if(!PyArg_ParseTuple(args, "f:delay", &delay))
 		return NULL;
 
 	Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0);
@@ -560,10 +556,10 @@
 		{
 			parent->factory = new AUD_DelayFactory(self->factory, delay);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(parent);
-			PyErr_SetString(AUDError, "Delayfactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -592,10 +588,10 @@
 		{
 			parent->factory = new AUD_DoubleFactory(self->factory, child->factory);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(parent);
-			PyErr_SetString(AUDError, "Doublefactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -609,7 +605,7 @@
 	float frequency;
 	float Q = 0.5;
 
-	if(!PyArg_ParseTuple(args, "f|f", &frequency, &Q))
+	if(!PyArg_ParseTuple(args, "f|f:highpass", &frequency, &Q))
 		return NULL;
 
 	Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0);
@@ -623,10 +619,10 @@
 		{
 			parent->factory = new AUD_HighpassFactory(self->factory, frequency, Q);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(parent);
-			PyErr_SetString(AUDError, "Highpassfactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -639,7 +635,7 @@
 {
 	float start, end;
 
-	if(!PyArg_ParseTuple(args, "ff", &start, &end))
+	if(!PyArg_ParseTuple(args, "ff:limit", &start, &end))
 		return NULL;
 
 	Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0);
@@ -653,10 +649,10 @@
 		{
 			parent->factory = new AUD_LimiterFactory(self->factory, start, end);
 		}
-		catch(AUD_Exception&)
+		catch(AUD_Exception& e)
 		{
 			Py_DECREF(parent);
-			PyErr_SetString(AUDError, "Limiterfactory couldn't be created!");
+			PyErr_SetString(AUDError, e.str);
 			return NULL;
 		}
 	}
@@ -669,7 +665,7 @@
 {
 	float factor;
 
-	if(!PyArg_ParseTuple(args, "f", &factor))
+	if(!PyArg_ParseTuple(args, "f:pitch", &factor))
 		return NULL;
 
 	Sound *parent = (Sound*)SoundType.tp_alloc(&SoundType, 0);
@@ -683,10 +679,10 @@
 		{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list