diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-16 13:13:29 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-16 13:13:29 +0400 |
commit | a90d30c8638a87234048060d8fcb385369b3daaf (patch) | |
tree | 7d2bb0c31f833b561cb6dd365fc23bc9185f7d1c /intern/audaspace | |
parent | cfcc4b4fcd7dabd0929db53fc5a9cf0833704259 (diff) |
3D Audio GSoC:
GameEngine Python access sound actuator's sound (with setting! :-D).
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/Python/AUD_PyAPI.cpp | 13 | ||||
-rw-r--r-- | intern/audaspace/Python/AUD_PyAPI.h | 1 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.cpp | 31 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_C-API.h | 12 |
4 files changed, 57 insertions, 0 deletions
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp index ac25ab34a69..b6e336eb329 100644 --- a/intern/audaspace/Python/AUD_PyAPI.cpp +++ b/intern/audaspace/Python/AUD_PyAPI.cpp @@ -2881,6 +2881,19 @@ Factory_empty() return FactoryType.tp_alloc(&FactoryType, 0); } +Factory* +checkFactory(PyObject* factory) +{ + if(!PyObject_TypeCheck(factory, &FactoryType)) + { + PyErr_SetString(PyExc_TypeError, "Object is not of type Factory!"); + return NULL; + } + + return (Factory*)factory; +} + + // ==================================================================== PyDoc_STRVAR(M_aud_doc, diff --git a/intern/audaspace/Python/AUD_PyAPI.h b/intern/audaspace/Python/AUD_PyAPI.h index 97e1e63b6eb..822aec06976 100644 --- a/intern/audaspace/Python/AUD_PyAPI.h +++ b/intern/audaspace/Python/AUD_PyAPI.h @@ -68,6 +68,7 @@ PyInit_aud(void); extern PyObject* Device_empty(); extern PyObject* Factory_empty(); +extern Factory* checkFactory(PyObject* factory); #ifdef __cplusplus } diff --git a/intern/audaspace/intern/AUD_C-API.cpp b/intern/audaspace/intern/AUD_C-API.cpp index b0050abe7ac..61d7616f694 100644 --- a/intern/audaspace/intern/AUD_C-API.cpp +++ b/intern/audaspace/intern/AUD_C-API.cpp @@ -227,6 +227,32 @@ PyObject* AUD_initPython() return module; } + +PyObject* AUD_getPythonFactory(AUD_Sound* sound) +{ + if(sound) + { + Factory* obj = (Factory*) Factory_empty(); + if(obj) + { + obj->factory = new AUD_Reference<AUD_IFactory>(*sound); + return (PyObject*) obj; + } + } + + return NULL; +} + +AUD_Sound* AUD_getPythonSound(PyObject* sound) +{ + Factory* factory = checkFactory(sound); + + if(!factory) + return NULL; + + return new AUD_Reference<AUD_IFactory>(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(factory->factory)); +} + #endif void AUD_lock() @@ -973,3 +999,8 @@ int AUD_doesPlayback() #endif return -1; } + +AUD_Sound* AUD_copy(AUD_Sound* sound) +{ + return new AUD_Reference<AUD_IFactory>(*sound); +} diff --git a/intern/audaspace/intern/AUD_C-API.h b/intern/audaspace/intern/AUD_C-API.h index 47dadd05555..3fdb9e7bca3 100644 --- a/intern/audaspace/intern/AUD_C-API.h +++ b/intern/audaspace/intern/AUD_C-API.h @@ -31,6 +31,10 @@ #ifndef AUD_CAPI #define AUD_CAPI +#ifdef WITH_PYTHON +#include "Python.h" +#endif + #ifdef __cplusplus extern "C" { #endif @@ -492,6 +496,14 @@ extern void AUD_setSyncCallback(AUD_syncFunction function, void* data); extern int AUD_doesPlayback(void); +extern AUD_Sound* AUD_copy(AUD_Sound* sound); + +#ifdef WITH_PYTHON +extern PyObject* AUD_getPythonFactory(AUD_Sound* sound); + +extern AUD_Sound* AUD_getPythonSound(PyObject* sound); +#endif + #ifdef __cplusplus } #endif |