changeset 12178:08d76f3dda8b draft

Added initial empty framework for the OpenAL sound driver.
author Michael Lutz <michi@icosahedron.de>
date Tue, 13 May 2008 21:32:59 +0200
parents 11f0c0521003
children ce025491d1e5
files config.lib configure projects/generate projects/generate.vbs projects/openttd_vs80.vcproj projects/openttd_vs90.vcproj source.list src/sound/openal_s.cpp src/sound/openal_s.h
diffstat 9 files changed, 129 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/config.lib
+++ b/config.lib
@@ -76,6 +76,7 @@
 	with_threads="1"
 	with_distcc="1"
 	with_ccache="1"
+	with_openal="1"
 
 	save_params_array="
 		build
@@ -143,6 +144,7 @@
 		with_threads
 		with_distcc
 		with_ccache
+		with_openal
 	CC CXX CFLAGS LDFLAGS"
 }
 
@@ -384,6 +386,10 @@
 			--with-threads)               with_threads="1";;
 			--with-threads=*)             with_threads="$optarg";;
 
+			--without-openal)             with_openal="0";;
+			--with-openal)                with_openal="2";;
+			--with-openal=*)              with_openal="$optarg";;
+
 			CC=* | --CC=*)                CC="$optarg";;
 			CXX=* | --CXX=*)              CXX="$optarg";;
 			CFLAGS=* | --CFLAGS=*)        CFLAGS="$optarg";;
@@ -667,6 +673,7 @@
 	detect_icu
 	detect_pspconfig
 	detect_libtimidity
+	detect_openal
 
 	if [ "$with_direct_music" != "0" ]; then
 		if [ "$os" != "MINGW" ] && [ "$os" != "CYGWIN" ]; then
@@ -1412,6 +1419,19 @@
 		CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
 	fi
 
+	if [ -n "$openal_config" ]; then
+		CFLAGS="$CFLAGS -DWITH_OPENAL"
+		CFLAGS="$CFLAGS -I`$openal_config --includedir | tr '\n\r' '  '`"
+		CFLAGS="$CFLAGS `$openal_config --cflags | tr '\n\r' '  '`"
+
+		LIBS="$LIBS -L`$openal_config --libdir | tr '\n\r' '  '`"
+		if [ "$enable_static" != "0" ]; then
+			LIBS="$LIBS `$openal_config --static --libs | tr '\n\r' '  '`"
+		else
+			LIBS="$LIBS `$openal_config --libs | tr '\n\r' '  '`"
+		fi
+	fi
+
 	CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
 
 	log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
@@ -2493,6 +2513,44 @@
 	rm -f tmp.iconv tmp.iconv.cpp
 }
 
+detect_openal() {
+	# 0 means no, 1 is auto-detect, 2 is force
+	if [ "$with_openal" = "0" ]; then
+		log 1 "checking OpenAL... disabled"
+
+		openal_config=""
+		return 0
+	fi
+
+	if [ "$with_openal" = "1" ] || [ "$with_openal" = "" ] || [ "$with_openal" = "2" ]; then
+		openal_config="openal-config"
+	else
+		openal_config="$with_openal"
+	fi
+
+	version=`$openal_config --version 2>/dev/null`
+	ret=$?
+	log 2 "executing $openal_config --version"
+	log 2 "  returned $version"
+	log 2 "  exit code $ret"
+
+	if [ -z "$version" ] || [ "$ret" != "0" ]; then
+		log 1 "checking OpenAL... not found"
+
+		# It was forced, so it should be found.
+		if [ "$with_openal" != "1" ]; then
+			log 1 "configure: error: openal-config couldn't be found"
+			log 1 "configure: error: you supplied '$with_openal', but it seems invalid"
+			exit 1
+		fi
+
+		openal_config=""
+		return 0
+	fi
+
+	log 1 "checking OpenAL... found"
+}
+
 _detect_sort() {
 	sort_test_in="d
 a
@@ -2906,6 +2964,7 @@
 	echo "  --with-psp-config[=psp-config] enables psp-config support (PSP ONLY)"
 	echo "  --disable-builtin-depend       disable use of builtin deps finder"
 	echo "  --with-makedepend[=makedepend] enables makedepend support"
+	echo "  --with-openal[=openal-config]  enables OpenAL support"
 	echo ""
 	echo "Some influential environment variables:"
 	echo "  CC                             C compiler command"
--- a/configure
+++ b/configure
@@ -116,6 +116,7 @@
 		if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0")  { next; }
 		if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" )        { next; }
 		if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0")       { next; }
+		if ($0 == "OPENAL"      && "'$with_openal'" == "0")        { next; }
 
 		skip += 1;
 
--- a/projects/generate
+++ b/projects/generate
@@ -36,6 +36,7 @@
 with_cocoa="0"
 enable_directmusic="1"
 with_threads="1"
+with_openal="1"
 file_prefix="..\\\\src\\\\"
 
 safety_check() {
@@ -96,6 +97,7 @@
 			if ($0 == "DIRECTMUSIC" && "'$enable_directmusic'" != "1") { next; }
 			if ($0 == "LIBTIMIDITY" && "'$libtimidity'" == "" )        { next; }
 			if ($0 == "HAVE_THREAD" && "'$with_threads'" == "0")       { next; }
+			if ($0 == "OPENAL"      && "'$with_openal'" == "0")        { next; }
 
 			skip += 1;
 
--- a/projects/generate.vbs
+++ b/projects/generate.vbs
@@ -151,7 +151,8 @@
 						line = "WIN32" Or _
 						line = "MSVC" Or _
 						line = "DIRECTMUSIC" Or _
-						line = "HAVE_THREAD" _
+						line = "HAVE_THREAD" Or _
+						line = "OPENAL" _
 					) Then skip = skip + 1
 					deep = deep + 1
 				Case "#"
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1260,6 +1260,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sound\openal_s.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\openttd.h"
 				>
 			</File>
@@ -3504,6 +3508,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sound\openal_s.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\sound\sdl_s.cpp"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1257,6 +1257,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sound\openal_s.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\openttd.h"
 				>
 			</File>
@@ -3501,6 +3505,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sound\openal_s.cpp"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\sound\sdl_s.cpp"
 				>
 			</File>
--- a/source.list
+++ b/source.list
@@ -243,6 +243,7 @@
 music/null_m.h
 sound/null_s.h
 video/null_v.h
+sound/openal_s.h
 openttd.h
 order_base.h
 order_func.h
@@ -894,6 +895,9 @@
 #if ALLEGRO
 	sound/allegro_s.cpp
 #end
+#if OPENAL
+	sound/openal_s.cpp
+#end
 #if SDL
 	sound/sdl_s.cpp
 #end
new file mode 100644
--- /dev/null
+++ b/src/sound/openal_s.cpp
@@ -0,0 +1,22 @@
+/* $Id$ */
+
+#ifdef WITH_OPENAL
+
+#include "../stdafx.h"
+
+#include "../driver.h"
+#include "../mixer.h"
+#include "openal_s.h"
+
+static FSoundDriver_OpenAL iFSoundDriver_OpenAL;
+
+const char *SoundDriver_OpenAL::Start(const char * const *parm)
+{
+	return NULL;
+}
+
+void SoundDriver_OpenAL::Stop()
+{
+}
+
+#endif /* WITH_OPENAL */
new file mode 100644
--- /dev/null
+++ b/src/sound/openal_s.h
@@ -0,0 +1,23 @@
+/* $Id$ */
+
+#ifndef SOUND_OPENAL_H
+#define SOUND_OPENAL_H
+
+#include "sound_driver.hpp"
+
+class SoundDriver_OpenAL: public SoundDriver {
+public:
+	/* virtual */ const char *Start(const char * const *param);
+
+	/* virtual */ void Stop();
+};
+
+class FSoundDriver_OpenAL: public SoundDriverFactory<FSoundDriver_OpenAL> {
+public:
+	static const int priority = 6;
+	/* virtual */ const char *GetName() { return "openal"; }
+	/* virtual */ const char *GetDescription() { return "OpenAL Sound Driver"; }
+	/* virtual */ Driver *CreateInstance() { return new SoundDriver_OpenAL(); }
+};
+
+#endif /* SOUND_OPENAL_H */