diff options
author | Jörg Müller <nexyon@gmail.com> | 2014-03-04 16:44:15 +0400 |
---|---|---|
committer | Jörg Müller <nexyon@gmail.com> | 2015-07-28 15:01:52 +0300 |
commit | 733073550f61cf4fbbe21aab33e9271915325109 (patch) | |
tree | a182ced91bb592815c097abf572bba999a9e8cdc /intern/audaspace | |
parent | 96dd213e7ecabeffc682aee40b4102296ab062de (diff) |
Audaspace: use standalone library.
- Added the cmake configuration option WITH_EXTERNAL_AUDASPACE.
- Fixes to build without standalone library as well.
Diffstat (limited to 'intern/audaspace')
-rw-r--r-- | intern/audaspace/CMakeLists.txt | 30 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_PyInit.cpp | 78 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Set.cpp | 69 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_Set.h | 74 |
4 files changed, 251 insertions, 0 deletions
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 5b810493663..7c6335166ec 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -21,6 +21,35 @@ remove_extra_strict_flags() +if(WITH_EXTERNAL_AUDASPACE) + + set(INC + . + ) + + set(INC_SYS + ${CAUDASPACE_INCLUDE_DIRS} + ${PYAUDASPACE_INCLUDE_DIRS} + ) + + set(SRC + intern/AUD_Set.cpp + intern/AUD_Set.h + ) + +if(WITH_PYTHON) + list(APPEND INC_SYS + ${PYTHON_INCLUDE_DIRS} + ) + list(APPEND SRC + intern/AUD_PyInit.cpp + intern/AUD_PyInit.h + ) + add_definitions(-DWITH_PYTHON) +endif() + +else() + set(INC . FX @@ -316,5 +345,6 @@ if(WITH_PYTHON) ) add_definitions(-DWITH_PYTHON) endif() +endif() blender_add_lib(bf_intern_audaspace "${SRC}" "${INC}" "${INC_SYS}") diff --git a/intern/audaspace/intern/AUD_PyInit.cpp b/intern/audaspace/intern/AUD_PyInit.cpp new file mode 100644 index 00000000000..8802f39929c --- /dev/null +++ b/intern/audaspace/intern/AUD_PyInit.cpp @@ -0,0 +1,78 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file audaspace/intern/AUD_PyInit.cpp + * \ingroup audaspaceintern + */ + +#include "AUD_PyInit.h" + +#include <audaspace/AUD_Sound.h> +#include <audaspace/python/PySound.h> +#include <audaspace/python/PyAPI.h> + +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_Sound* sound = sound_get_factory((void *) lptr); + + if (sound) { + Sound *obj = (Sound *)Sound_empty(); + if (obj) { + obj->sound = AUD_copy(sound); + 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(void) +{ + PyObject *module = PyInit_aud(); + PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL)); + PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module); + + return module; +} + diff --git a/intern/audaspace/intern/AUD_Set.cpp b/intern/audaspace/intern/AUD_Set.cpp new file mode 100644 index 00000000000..eb04e37f666 --- /dev/null +++ b/intern/audaspace/intern/AUD_Set.cpp @@ -0,0 +1,69 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file audaspace/intern/AUD_Set.cpp + * \ingroup audaspaceintern + */ + +#include <set> + +#include "AUD_Set.h" + +void *AUD_createSet() +{ + return new std::set<void *>(); +} + +void AUD_destroySet(void *set) +{ + delete reinterpret_cast<std::set<void *>*>(set); +} + +char AUD_removeSet(void *set, void *entry) +{ + if (set) + return reinterpret_cast<std::set<void *>*>(set)->erase(entry); + return 0; +} + +void AUD_addSet(void *set, void *entry) +{ + if (entry) + reinterpret_cast<std::set<void *>*>(set)->insert(entry); +} + +void *AUD_getSet(void *set) +{ + if (set) { + std::set<void *>* rset = reinterpret_cast<std::set<void *>*>(set); + if (!rset->empty()) { + std::set<void *>::iterator it = rset->begin(); + void *result = *it; + rset->erase(it); + return result; + } + } + + return (void*) 0; +} diff --git a/intern/audaspace/intern/AUD_Set.h b/intern/audaspace/intern/AUD_Set.h new file mode 100644 index 00000000000..ca1419293b0 --- /dev/null +++ b/intern/audaspace/intern/AUD_Set.h @@ -0,0 +1,74 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * Copyright 2009-2011 Jörg Hermann Müller + * + * This file is part of AudaSpace. + * + * Audaspace is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * AudaSpace is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Audaspace; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file AUD_Set.h + * \ingroup audaspace + */ + +#ifndef __AUD_SET_H__ +#define __AUD_SET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Creates a new set. + * \return The new set. + */ +extern void *AUD_createSet(void); + +/** + * Deletes a set. + * \param set The set to delete. + */ +extern void AUD_destroySet(void *set); + +/** + * Removes an entry from a set. + * \param set The set work on. + * \param entry The entry to remove. + * \return Whether the entry was in the set or not. + */ +extern char AUD_removeSet(void *set, void *entry); + +/** + * Adds a new entry to a set. + * \param set The set work on. + * \param entry The entry to add. + */ +extern void AUD_addSet(void *set, void *entry); + +/** + * Removes one entry from a set and returns it. + * \param set The set work on. + * \return The entry or NULL if the set is empty. + */ +extern void *AUD_getSet(void *set); + +#ifdef __cplusplus +} +#endif + +#endif //__AUD_SET_H__ |