Browse Source

Move luaopen_love_audio to love.audio.openal

--HG--
branch : minor
Bart van Strien 14 years ago
parent
commit
254bd29244

+ 2 - 2
src/love.cpp

@@ -41,7 +41,7 @@
 #include <SDL.h>
 
 // Modules
-#include <audio/wrap_Audio.h>
+#include <audio/openal/wrap_Audio.h>
 #include <event/sdl/wrap_Event.h>
 #include <filesystem/physfs/wrap_Filesystem.h>
 #include <font/freetype/wrap_Font.h>
@@ -66,7 +66,7 @@
 #ifdef LOVE_BUILD_STANDALONE
 
 static const luaL_Reg modules[] = {
-	{ "love.audio", love::audio::luaopen_love_audio },
+	{ "love.audio.openal", love::audio::openal::luaopen_love_audio },
 	{ "love.event.sdl", love::event::sdl::luaopen_love_event },
 	{ "love.filesystem.physfs", love::filesystem::physfs::luaopen_love_filesystem },
 	{ "love.font.freetype", love::font::freetype::luaopen_love_font },

+ 116 - 0
src/modules/audio/openal/wrap_Audio.cpp

@@ -0,0 +1,116 @@
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+*
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+*
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+*
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+// LOVE
+#include "wrap_Audio.h"
+
+#include "Audio.h"
+#include "audio/null/Audio.h"
+
+#include <scripts/audio.lua.h>
+
+#include <common/runtime.h>
+
+namespace love
+{
+namespace audio
+{
+	extern Audio * instance;
+namespace openal
+{
+	// List of functions to wrap.
+	static const luaL_Reg functions[] = {
+		{ "getNumSources", w_getNumSources },
+		{ "newSource1", w_newSource1 },
+		{ "play", w_play },
+		{ "stop", w_stop },
+		{ "pause", w_pause },
+		{ "resume", w_resume },
+		{ "rewind", w_rewind },
+		{ "setVolume", w_setVolume },
+		{ "getVolume", w_getVolume },
+		{ "setPosition", w_setPosition },
+		{ "getPosition", w_getPosition },
+		{ "setOrientation", w_setOrientation },
+		{ "getOrientation", w_getOrientation },
+		{ "setVelocity", w_setVelocity },
+		{ "getVelocity", w_getVelocity },
+		/*{ "record", w_record },
+		{ "getRecordedData", w_getRecordedData },
+		{ "stopRecording", w_stopRecording },*/
+		{ 0, 0 }
+	};
+
+	static const lua_CFunction types[] = {
+		luaopen_source,
+		0
+	};
+
+	int luaopen_love_audio(lua_State * L)
+	{
+		if(instance == 0)
+		{
+			// Try OpenAL first.
+			try
+			{
+				instance = new love::audio::openal::Audio();
+			}
+			catch(love::Exception & e)
+			{
+				std::cout << e.what() << std::endl;
+			}
+		}
+		else
+			instance->retain();
+
+		if(instance == 0)
+		{
+			// Fall back to nullaudio.
+			try
+			{
+				instance = new love::audio::null::Audio();
+			}
+			catch(love::Exception & e)
+			{
+				std::cout << e.what() << std::endl;
+			}
+		}
+
+		if(instance == 0)
+			return luaL_error(L, "Could not open any audio module.");
+
+		WrappedModule w;
+		w.module = instance;
+		w.name = "audio";
+		w.flags = MODULE_T;
+		w.functions = functions;
+		w.types = types;
+
+		luax_register_module(L, w);
+
+		if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
+			lua_call(L, 0, 0);
+
+		return 0;
+	}
+	
+} // openal
+} // audio
+} // love

+ 39 - 0
src/modules/audio/openal/wrap_Audio.h

@@ -0,0 +1,39 @@
+/**
+* Copyright (c) 2006-2011 LOVE Development Team
+* 
+* This software is provided 'as-is', without any express or implied
+* warranty.  In no event will the authors be held liable for any damages
+* arising from the use of this software.
+* 
+* Permission is granted to anyone to use this software for any purpose,
+* including commercial applications, and to alter it and redistribute it
+* freely, subject to the following restrictions:
+* 
+* 1. The origin of this software must not be misrepresented; you must not
+*    claim that you wrote the original software. If you use this software
+*    in a product, an acknowledgment in the product documentation would be
+*    appreciated but is not required.
+* 2. Altered source versions must be plainly marked as such, and must not be
+*    misrepresented as being the original software.
+* 3. This notice may not be removed or altered from any source distribution.
+**/
+
+#ifndef LOVE_AUDIO_OPENAL_WRAP_AUDIO_H
+#define LOVE_AUDIO_OPENAL_WRAP_AUDIO_H
+
+// LOVE
+#include "audio/wrap_Audio.h"
+
+namespace love
+{
+namespace audio
+{
+namespace openal
+{
+	extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
+
+} // openal
+} // audio
+} // love
+
+#endif // LOVE_AUDIO_OPENAL_WRAP_AUDIO_H

+ 1 - 78
src/modules/audio/wrap_Audio.cpp

@@ -21,7 +21,6 @@
 // LOVE
 #include "wrap_Audio.h"
 
-#include "openal/Audio.h"
 #include "null/Audio.h"
 
 #include <scripts/audio.lua.h>
@@ -32,7 +31,7 @@ namespace love
 {
 namespace audio
 {
-	static Audio * instance = 0;
+	Audio * instance = 0;
 
 	int w_getNumSources(lua_State * L)
 	{
@@ -235,81 +234,5 @@ namespace audio
 	}
 	
 
-	// List of functions to wrap.
-	static const luaL_Reg functions[] = {
-		{ "getNumSources", w_getNumSources },
-		{ "newSource1", w_newSource1 },
-		{ "play", w_play },
-		{ "stop", w_stop },
-		{ "pause", w_pause },
-		{ "resume", w_resume },
-		{ "rewind", w_rewind },
-		{ "setVolume", w_setVolume },
-		{ "getVolume", w_getVolume },
-		{ "setPosition", w_setPosition },
-		{ "getPosition", w_getPosition },
-		{ "setOrientation", w_setOrientation },
-		{ "getOrientation", w_getOrientation },
-		{ "setVelocity", w_setVelocity },
-		{ "getVelocity", w_getVelocity },
-		/*{ "record", w_record },
-		{ "getRecordedData", w_getRecordedData },
-		{ "stopRecording", w_stopRecording },*/
-		{ 0, 0 }
-	};
-
-	static const lua_CFunction types[] = {
-		luaopen_source,
-		0
-	};
-
-	int luaopen_love_audio(lua_State * L)
-	{
-		if(instance == 0)
-		{
-			// Try OpenAL first.
-			try
-			{
-				instance = new love::audio::openal::Audio();
-			}
-			catch(love::Exception & e)
-			{
-				std::cout << e.what() << std::endl;
-			}
-		}
-		else
-			instance->retain();
-
-		if(instance == 0)
-		{
-			// Fall back to nullaudio.
-			try
-			{
-				instance = new love::audio::null::Audio();
-			}
-			catch(love::Exception & e)
-			{
-				std::cout << e.what() << std::endl;
-			}
-		}
-
-		if(instance == 0)
-			return luaL_error(L, "Could not open any audio module.");
-
-		WrappedModule w;
-		w.module = instance;
-		w.name = "audio";
-		w.flags = MODULE_T;
-		w.functions = functions;
-		w.types = types;
-
-		luax_register_module(L, w);
-
-		if (luaL_loadbuffer(L, (const char *)audio_lua, sizeof(audio_lua), "audio.lua") == 0)
-			lua_call(L, 0, 0);
-
-		return 0;
-	}
-
 } // audio
 } // love

+ 0 - 1
src/modules/audio/wrap_Audio.h

@@ -50,7 +50,6 @@ namespace audio
 	int w_getRecordedData(lua_State * L);
 	int w_stopRecording(lua_State * L);
 	int w_canRecord(lua_State * L);
-	extern "C" LOVE_EXPORT int luaopen_love_audio(lua_State * L);
 
 } // audio
 } // love

+ 1 - 1
src/scripts/boot.lua

@@ -276,7 +276,7 @@ function love.init()
 	end
 
 	local defaultmodules = {
-		audio = false,
+		audio = "openal",
 		event = "sdl",
 		filesystem = "physfs",
 		font = "freetype",

File diff suppressed because it is too large
+ 1682 - 1744
src/scripts/boot.lua.h


Some files were not shown because too many files changed in this diff