[Bf-blender-cvs] [7330735] master: Audaspace: use standalone library.

Jörg Müller noreply at git.blender.org
Tue Jul 28 14:10:17 CEST 2015


Commit: 733073550f61cf4fbbe21aab33e9271915325109
Author: Jörg Müller
Date:   Tue Mar 4 13:44:15 2014 +0100
Branches: master
https://developer.blender.org/rB733073550f61cf4fbbe21aab33e9271915325109

Audaspace: use standalone library.

- Added the cmake configuration option WITH_EXTERNAL_AUDASPACE.
- Fixes to build without standalone library as well.

===================================================================

M	CMakeLists.txt
A	build_files/cmake/Modules/FindAudaspace.cmake
M	build_files/cmake/macros.cmake
M	intern/audaspace/CMakeLists.txt
A	intern/audaspace/intern/AUD_PyInit.cpp
A	intern/audaspace/intern/AUD_Set.cpp
A	intern/audaspace/intern/AUD_Set.h
M	source/blender/blenkernel/BKE_sound.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/blender.c
M	source/blender/blenkernel/intern/nla.c
M	source/blender/blenkernel/intern/sequencer.c
M	source/blender/blenkernel/intern/sound.c
M	source/blender/blenkernel/intern/writeffmpeg.c
M	source/blender/editors/sound/CMakeLists.txt
M	source/blender/editors/sound/sound_ops.c
M	source/blender/editors/space_graph/CMakeLists.txt
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_sequencer/CMakeLists.txt
M	source/blender/editors/space_sequencer/sequencer_add.c
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/rna_scene.c
M	source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
M	source/gameengine/BlenderRoutines/CMakeLists.txt
M	source/gameengine/Converter/CMakeLists.txt
M	source/gameengine/Converter/KX_ConvertActuators.cpp
M	source/gameengine/GamePlayer/ghost/CMakeLists.txt
M	source/gameengine/GamePlayer/ghost/GPG_Application.cpp
M	source/gameengine/Ketsji/CMakeLists.txt
M	source/gameengine/Ketsji/KX_KetsjiEngine.cpp
M	source/gameengine/Ketsji/KX_SoundActuator.cpp
M	source/gameengine/Ketsji/KX_SoundActuator.h

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd19d80..cac75d3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -247,6 +247,7 @@ option(WITH_HEADLESS      "Build without graphical support (renderfarm, server m
 mark_as_advanced(WITH_HEADLESS)
 
 option(WITH_AUDASPACE    "Build with blenders audio library (only disable if you know what you're doing!)" ON)
+option(WITH_EXTERNAL_AUDASPACE "Build with external audaspace library installed on the system (only enable if you know what you're doing!)" OFF)
 mark_as_advanced(WITH_AUDASPACE)
 
 option(WITH_OPENMP        "Enable OpenMP (has to be supported by the compiler)" ON)
@@ -883,6 +884,13 @@ if(UNIX AND NOT APPLE)
 	endif()
 
 	# Audio IO
+	if(WITH_EXTERNAL_AUDASPACE)
+		find_package_wrapper(Audaspace)
+		if(NOT AUDASPACE_FOUND OR NOT CAUDASPACE_FOUND)
+			message(FATAL_ERROR "Audaspace external library not found!")
+		endif()
+	endif()
+
 	if(WITH_OPENAL)
 		find_package_wrapper(OpenAL)
 		if(NOT OPENAL_FOUND)
diff --git a/build_files/cmake/Modules/FindAudaspace.cmake b/build_files/cmake/Modules/FindAudaspace.cmake
new file mode 100644
index 0000000..361c1bf
--- /dev/null
+++ b/build_files/cmake/Modules/FindAudaspace.cmake
@@ -0,0 +1,76 @@
+# - Try to find audaspace
+# Once done, this will define
+#
+#  AUDASPACE_FOUND - system has audaspace
+#  AUDASPACE_INCLUDE_DIRS - the audaspace include directories
+#  AUDASPACE_LIBRARIES - link these to use audaspace
+#  CAUDASPACE_FOUND - system has audaspace's C binding
+#  CAUDASPACE_INCLUDE_DIRS - the audaspace's C binding include directories
+#  CAUDASPACE_LIBRARIES - link these to use audaspace's C binding
+#  PYAUDASPACE_FOUND - system has audaspace's python binding
+#  PYAUDASPACE_INCLUDE_DIRS - the audaspace's python binding include directories
+#  PYAUDASPACE_LIBRARIES - link these to use audaspace's python binding
+
+# Use pkg-config to get hints about paths
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+	pkg_check_modules(AUDASPACE_PKGCONF audaspace)
+endif(PKG_CONFIG_FOUND)
+
+# Include dir
+find_path(AUDASPACE_INCLUDE_DIR
+	NAMES audaspace/ISound.h
+	PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
+)
+
+# Library
+find_library(AUDASPACE_LIBRARY
+	NAMES audaspace
+	PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
+)
+
+# Include dir
+find_path(CAUDASPACE_INCLUDE_DIR
+	NAMES audaspace/AUD_Sound.h
+	PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
+)
+
+# Library
+find_library(CAUDASPACE_LIBRARY
+	NAMES caudaspace
+	PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
+)
+
+# Include dir
+find_path(PYAUDASPACE_INCLUDE_DIR
+	NAMES audaspace/python/PyAPI.h
+	PATHS ${AUDASPACE_PKGCONF_INCLUDE_DIRS}
+)
+
+# Library
+find_library(PYAUDASPACE_LIBRARY
+	NAMES pyaudaspace
+	PATHS ${AUDASPACE_PKGCONF_LIBRARY_DIRS}
+)
+
+find_package(PackageHandleStandardArgs)
+find_package_handle_standard_args(Audaspace  DEFAULT_MSG  AUDASPACE_LIBRARY AUDASPACE_INCLUDE_DIR)
+find_package_handle_standard_args(CAudaspace  DEFAULT_MSG  CAUDASPACE_LIBRARY CAUDASPACE_INCLUDE_DIR)
+find_package_handle_standard_args(PyAudaspace  DEFAULT_MSG  PYAUDASPACE_LIBRARY PYAUDASPACE_INCLUDE_DIR)
+
+if(AUDASPACE_FOUND)
+  set(AUDASPACE_LIBRARIES ${AUDASPACE_LIBRARY})
+  set(AUDASPACE_INCLUDE_DIRS ${AUDASPACE_INCLUDE_DIR})
+endif(AUDASPACE_FOUND)
+
+if(CAUDASPACE_FOUND)
+  set(CAUDASPACE_LIBRARIES ${CAUDASPACE_LIBRARY})
+  set(CAUDASPACE_INCLUDE_DIRS ${CAUDASPACE_INCLUDE_DIR})
+endif(CAUDASPACE_FOUND)
+
+if(PYAUDASPACE_FOUND)
+  set(PYAUDASPACE_LIBRARIES ${PYAUDASPACE_LIBRARY})
+  set(PYAUDASPACE_INCLUDE_DIRS ${PYAUDASPACE_INCLUDE_DIR})
+endif(PYAUDASPACE_FOUND)
+
+mark_as_advanced(AUDASPACE_LIBRARY AUDASPACE_LIBRARIES AUDASPACE_INCLUDE_DIR AUDASPACE_INCLUDE_DIRS CAUDASPACE_LIBRARY CAUDASPACE_LIBRARIES CAUDASPACE_INCLUDE_DIR CAUDASPACE_INCLUDE_DIRS PYAUDASPACE_LIBRARY PYAUDASPACE_LIBRARIES PYAUDASPACE_INCLUDE_DIR PYAUDASPACE_INCLUDE_DIRS)
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 34f6a36..de2109b 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -343,6 +343,9 @@ function(setup_liblinks
 	if(WITH_BULLET AND WITH_SYSTEM_BULLET)
 		target_link_libraries(${target} ${BULLET_LIBRARIES})
 	endif()
+	if(WITH_EXTERNAL_AUDASPACE)
+		target_link_libraries(${target} ${CAUDASPACE_LIBRARIES} ${PYAUDASPACE_LIBRARIES})
+	endif()
 	if(WITH_OPENAL)
 		target_link_libraries(${target} ${OPENAL_LIBRARY})
 	endif()
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt
index 5b81049..7c63351 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 0000000..8802f39
--- /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 0000000..eb04e37
--- /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 0000000..ca14192
--- /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

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list