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-06-06 02:06:29 +0400
committerJoerg Mueller <nexyon@gmail.com>2011-06-06 02:06:29 +0400
commitef5f78ecc7a6a7aac04207d3733087db8d03f5a6 (patch)
tree1038ed34bb7bfb794b81eefd21c437ab6ca5d0c8 /intern/audaspace
parentf2daf2ca6b9aec02ebe8108c6354d1aebc869e99 (diff)
3D Audio GSoC:
Making it possible to access blenders internal sounds via Python.
Diffstat (limited to 'intern/audaspace')
-rw-r--r--intern/audaspace/Python/AUD_PyAPI.cpp6
-rw-r--r--intern/audaspace/Python/AUD_PyAPI.h4
-rw-r--r--intern/audaspace/intern/AUD_C-API.cpp40
3 files changed, 47 insertions, 3 deletions
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp
index 53dfedee5eb..ac25ab34a69 100644
--- a/intern/audaspace/Python/AUD_PyAPI.cpp
+++ b/intern/audaspace/Python/AUD_PyAPI.cpp
@@ -2875,6 +2875,12 @@ Device_empty()
return DeviceType.tp_alloc(&DeviceType, 0);
}
+PyObject *
+Factory_empty()
+{
+ return FactoryType.tp_alloc(&FactoryType, 0);
+}
+
// ====================================================================
PyDoc_STRVAR(M_aud_doc,
diff --git a/intern/audaspace/Python/AUD_PyAPI.h b/intern/audaspace/Python/AUD_PyAPI.h
index d1a70ce892d..97e1e63b6eb 100644
--- a/intern/audaspace/Python/AUD_PyAPI.h
+++ b/intern/audaspace/Python/AUD_PyAPI.h
@@ -66,8 +66,8 @@ typedef struct {
PyMODINIT_FUNC
PyInit_aud(void);
-extern PyObject *
-Device_empty();
+extern PyObject* Device_empty();
+extern PyObject* Factory_empty();
#ifdef __cplusplus
}
diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp
index 3d78a5945df..08fb55f7605 100644
--- a/intern/audaspace/intern/AUD_C-API.cpp
+++ b/intern/audaspace/intern/AUD_C-API.cpp
@@ -181,10 +181,48 @@ static PyMethodDef meth_getcdevice[] = {{ "device", (PyCFunction)AUD_getCDevice,
":return: The application's :class:`Device`.\n"
":rtype: :class:`Device`"}};
+extern "C" {
+extern void* sound_get_factory(void* sound);
+}
+
+static PyObject* AUD_getSoundFromPointer(PyObject* self, PyObject* args)
+{
+ long int lptr;
+
+ if(PyArg_Parse(args, "l:_sound_from_pointer", &lptr))
+ {
+ if(lptr)
+ {
+ AUD_Reference<AUD_IFactory>* factory = (AUD_Reference<AUD_IFactory>*) sound_get_factory((void*) lptr);
+
+ if(factory)
+ {
+ Factory* obj = (Factory*) Factory_empty();
+ if(obj)
+ {
+ obj->factory = new AUD_Reference<AUD_IFactory>(*factory);
+ return (PyObject*) obj;
+ }
+ }
+ }
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyMethodDef meth_sound_from_pointer[] = {{ "_sound_from_pointer", (PyCFunction)AUD_getSoundFromPointer, METH_O,
+ "_sound_from_pointer(pointer)\n\n"
+ "Returns the corresponding :class:`Factory` object.\n\n"
+ ":arg pointer: The pointer to the bSound object as long.\n"
+ ":type pointer: long\n"
+ ":return: The corresponding :class:`Factory` object.\n"
+ ":rtype: :class:`Factory`"}};
+
PyObject* AUD_initPython()
{
PyObject* module = PyInit_aud();
- PyModule_AddObject(module, "device", (PyObject *)PyCFunction_New(meth_getcdevice, NULL));
+ PyModule_AddObject(module, "device", (PyObject*)PyCFunction_New(meth_getcdevice, NULL));
+ PyModule_AddObject(module, "_sound_from_pointer", (PyObject*)PyCFunction_New(meth_sound_from_pointer, NULL));
PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module);
return module;