[mupen64plus-audio-sdl] 62/163: Imported Upstream version 1.99.5~hg20110828
Sven Eckelmann
ecsv-guest at moszumanska.debian.org
Thu Nov 26 05:53:14 UTC 2015
This is an automated email from the git hooks/post-receive script.
ecsv-guest pushed a commit to branch armhf_test
in repository mupen64plus-audio-sdl.
commit 20aad2e048a469112609eb80c726a5fb5a87cb1f
Author: Sven Eckelmann <sven at narfation.org>
Date: Sun Aug 28 18:46:16 2011 +0200
Imported Upstream version 1.99.5~hg20110828
---
projects/unix/Makefile | 152 ++++++++++++++++++++++++++-----------------------
src/main.c | 52 ++++++++++++-----
src/main.h | 4 ++
src/osal_preproc.h | 2 +-
4 files changed, 124 insertions(+), 86 deletions(-)
diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index 7e24a25..78f4c55 100644
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -49,6 +49,12 @@ ifeq ("$(UNAME)","FreeBSD")
SHARED = -shared
SO_EXTENSION = so
endif
+ifeq ("$(UNAME)","OpenBSD")
+ OS = FREEBSD
+ SHARED = -shared
+ SO_EXTENSION = so
+ $(warning OS type "$(UNAME)" not officially supported.')
+endif
ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
OS = LINUX
SHARED = -shared
@@ -66,71 +72,77 @@ ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
CPU := X86
ifeq ("$(BITS)", "32")
ARCH_DETECTED := 64BITS_32
+ PIC ?= 0
else
ARCH_DETECTED := 64BITS
+ PIC ?= 1
endif
endif
ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
CPU := X86
ARCH_DETECTED := 32BITS
+ PIC ?= 0
+endif
+ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
+ CPU := PPC
+ ARCH_DETECTED := 32BITS
+ BIG_ENDIAN := 1
+ PIC ?= 1
+ $(warning Architecture "$(HOST_CPU)" not officially supported.')
+endif
+ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
+ CPU := PPC
+ ARCH_DETECTED := 64BITS
+ BIG_ENDIAN := 1
+ PIC ?= 1
+ $(warning Architecture "$(HOST_CPU)" not officially supported.')
endif
-# PPC doesn't work yet
-#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
-# CPU := PPC
-# ARCH_DETECTED := 32BITS
-#endif
-#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
-# CPU := PPC
-# ARCH_DETECTED := 64BITS
-#endif
ifeq ("$(CPU)","NONE")
$(error CPU type "$(HOST_CPU)" not supported. Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
endif
-# base CFLAGS, LIBS, and LDFLAGS
-CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src
+# base CFLAGS, LDLIBS, and LDFLAGS
+OPTFLAGS ?= -O3
+CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
+LDFLAGS += $(SHARED)
-# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
-# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
-ifeq ($(ARCH_DETECTED), 64BITS)
- CFLAGS += -fpic -DPIC
+# Since we are building a shared library, we must compile with -fPIC on some architectures
+# On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
+ifeq ($(PIC), 1)
+ CFLAGS += -fPIC
+ LDFLAGS += -fPIC
endif
+
+ifeq ($(BIG_ENDIAN), 1)
+ CFLAGS += -DM64P_BIG_ENDIAN
+endif
+
# tweak flags for 32-bit build on 64-bit system
ifeq ($(ARCH_DETECTED), 64BITS_32)
ifeq ($(OS), FREEBSD)
$(error Do not use the BITS=32 option with FreeBSD, use -m32 and -m elf_i386)
endif
CFLAGS += -m32
- LDFLAGS += -m32 -m elf_i386
+ LDFLAGS += -m32 -Wl,-m,elf_i386
endif
# set special flags per-system
ifeq ($(OS), LINUX)
- ifeq ($(CPU), X86)
- ifeq ($(ARCH_DETECTED), 64BITS)
- CFLAGS += -pipe -O3 -march=athlon64
- LDFLAGS += -ldl
- else
- CFLAGS += -pipe -O3 -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
- LDFLAGS += -ldl
- endif
- endif
+ LDLIBS += -ldl
endif
ifeq ($(OS), OSX)
ifeq ($(CPU), X86)
ifeq ($(ARCH_DETECTED), 64BITS)
CFLAGS += -pipe -O3 -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
- LDFLAGS += -arch x86_64 -ldl
+ LDFLAGS += -arch x86_64
+ LDLIBS += -ldl
else
CFLAGS += -pipe -O3 -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
- LDFLAGS += -arch i686 -ldl
+ LDFLAGS += -arch i686
+ LDLIBS += -ldl
endif
endif
endif
-ifeq ($(CPU), PPC)
- CFLAGS += -mcpu=powerpc
- LDFLAGS += -ldl
-endif
# test for presence of SDL
ifeq ($(shell which sdl-config 2>/dev/null),)
@@ -138,17 +150,17 @@ ifeq ($(shell which sdl-config 2>/dev/null),)
endif
ifeq ($(OS),FREEBSD)
CFLAGS += $(shell sdl-config --cflags)
- LDFLAGS += $(shell sdl-config --libs)
+ LDLIBS += $(shell sdl-config --libs)
endif
ifeq ($(OS),OSX)
CFLAGS += $(shell sdl-config --cflags)
# sdl-config on mac screws up when we're trying to build a library and not an executable
# SDL 1.3 is supposed to fix that, if it's ever released
- LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
+ LDLIBS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
endif
ifeq ($(OS),LINUX)
CFLAGS += $(shell sdl-config --cflags)
- LDFLAGS += $(shell sdl-config --libs)
+ LDLIBS += $(shell sdl-config --libs)
endif
# test for presence of libsamplerate
@@ -156,7 +168,7 @@ ifneq ($(strip $(shell pkg-config samplerate --modversion 2> /dev/null)),)
ifneq ($(NO_RESAMP), 1)
# set libsamplerate flags and libraries
CFLAGS += $(shell pkg-config samplerate --cflags) -DUSE_SRC
- LDFLAGS += $(shell pkg-config samplerate --libs)
+ LDLIBS += $(shell pkg-config samplerate --libs)
endif
else
# warn user
@@ -185,25 +197,28 @@ else
endif
endif
-# set shell function names
-CC ?= gcc
-CXX ?= g++
-LD ?= g++
-INSTALL ?= install
-ifeq ($(OS),LINUX)
- STRIP ?= strip -s
-endif
-ifeq ($(OS),OSX)
- STRIP ?= strip -x
+# reduced compile output when running make without V=1
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+ Q_CC = @echo ' CC '$@;
+ Q_LD = @echo ' LD '$@;
endif
-ifeq ($(OS),FREEBSD)
- STRIP += strip -s
endif
+# set base program pointers and flags
+CC ?= gcc
+RM ?= rm -f
+INSTALL ?= install
+MKDIR ?= mkdir -p
+COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
+LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
+
# set special flags for given Makefile parameters
ifeq ($(DEBUG),1)
CFLAGS += -g
- STRIP = true # disable binary strip
+ INSTALL_STRIP_FLAG ?=
+else
+ INSTALL_STRIP_FLAG ?= -s
endif
# set installation options
@@ -211,7 +226,10 @@ ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
ifeq ($(LIBDIR),)
- LIBDIR := $(PREFIX)/lib/mupen64plus
+ LIBDIR := $(PREFIX)/lib
+endif
+ifeq ($(PLUGINDIR),)
+ PLUGINDIR := $(LIBDIR)/mupen64plus
endif
SRCDIR = ../../src
@@ -226,20 +244,12 @@ SOURCE = \
# generate a list of object files build, make a temporary directory for them
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
OBJDIRS = $(dir $(OBJECTS))
-$(shell mkdir -p $(OBJDIRS))
+$(shell $(MKDIR) $(OBJDIRS))
# build dependency files
CFLAGS += -MD
-include $(OBJECTS:.o=.d)
-# reduced compile output when running make without V=1
-ifneq ($(findstring $(MAKEFLAGS),s),s)
-ifndef V
- Q_CC = @echo ' CC '$@;
- Q_LD = @echo ' LD '$@;
-endif
-endif
-
# build targets
TARGET = mupen64plus-audio-sdl.$(SO_EXTENSION)
@@ -254,35 +264,37 @@ targets:
@echo " Options:"
@echo " BITS=32 == build 32-bit binaries on 64-bit machine"
@echo " APIDIR=path == path to find Mupen64Plus Core headers"
+ @echo " OPTFLAGS=flag == compiler optimization (default: -O3)"
+ @echo " PIC=(1|0) == Force enable/disable of position independent code"
@echo " Install Options:"
@echo " PREFIX=path == install/uninstall prefix (default: /usr/local)"
- @echo " LIBDIR=path == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
+ @echo " LIBDIR=path == library prefix (default: PREFIX/lib)"
+ @echo " PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
@echo " DESTDIR=path == path to prepend to all installation paths (only for packagers)"
@echo " Debugging Options:"
@echo " DEBUG=1 == add debugging symbols"
+ @echo " V=1 == show verbose compiler output"
all: $(TARGET)
install: $(TARGET)
- $(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
- $(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
+ $(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
+ $(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
uninstall:
- rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
+ $(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
clean:
- rm -rf ./_obj/* $(TARGET)
- rmdir ./_obj
+ $(RM) -r ./_obj $(TARGET)
rebuild: clean all
-# build rules
-$(TARGET): $(OBJECTS)
- $(Q_LD)$(CC) $(SHARED) $^ $(LDFLAGS) -o $@
- $(STRIP) $@
-
+# standard build rules
$(OBJDIR)/%.o: $(SRCDIR)/%.c
- $(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
+ $(COMPILE.c) -o $@ $<
+$(TARGET): $(OBJECTS)
+ $(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
+.PHONY: all clean install uninstall targets
diff --git a/src/main.c b/src/main.c
index 0675812..5b8c9f1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,8 +33,10 @@
#include <samplerate.h>
#endif
+#define M64P_PLUGIN_PROTOTYPES 1
#include "m64p_types.h"
#include "m64p_plugin.h"
+#include "m64p_common.h"
#include "m64p_config.h"
#include "main.h"
@@ -124,8 +126,8 @@ static int OutputFreq;
// Prototype of local functions
static void my_audio_callback(void *userdata, unsigned char *stream, int len);
static void InitializeAudio(int freq);
-static void ReadConfig();
-static void InitializeSDL();
+static void ReadConfig(void);
+static void InitializeSDL(void);
static int critical_failure = 0;
@@ -144,7 +146,7 @@ ptr_ConfigGetParamBool ConfigGetParamBool = NULL;
ptr_ConfigGetParamString ConfigGetParamString = NULL;
/* Global functions */
-void DebugMessage(int level, const char *message, ...)
+static void DebugMessage(int level, const char *message, ...)
{
char msgbuf[1024];
va_list args;
@@ -164,6 +166,10 @@ void DebugMessage(int level, const char *message, ...)
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
void (*DebugCallback)(void *, int, const char *))
{
+ ptr_CoreGetAPIVersions CoreAPIVersionFunc;
+
+ int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
+
if (l_PluginInit)
return M64ERR_ALREADY_INIT;
@@ -171,6 +177,22 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
l_DebugCallback = DebugCallback;
l_DebugCallContext = Context;
+ /* attach and call the CoreGetAPIVersions function, check Config API version for compatibility */
+ CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreLibHandle, "CoreGetAPIVersions");
+ if (CoreAPIVersionFunc == NULL)
+ {
+ DebugMessage(M64MSG_ERROR, "Core emulator broken; no CoreAPIVersionFunc() function found.");
+ return M64ERR_INCOMPATIBLE;
+ }
+
+ (*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
+ if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
+ {
+ DebugMessage(M64MSG_ERROR, "Emulator core Config API (v%i.%i.%i) incompatible with plugin (v%i.%i.%i)",
+ VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
+ return M64ERR_INCOMPATIBLE;
+ }
+
/* Get the core config function pointers from the library handle */
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreLibHandle, "ConfigSetParameter");
@@ -241,7 +263,7 @@ EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *Plugi
*PluginVersion = SDL_AUDIO_PLUGIN_VERSION;
if (APIVersion != NULL)
- *APIVersion = PLUGIN_API_VERSION;
+ *APIVersion = AUDIO_PLUGIN_API_VERSION;
if (PluginNamePtr != NULL)
*PluginNamePtr = "Mupen64Plus SDL Audio Plugin";
@@ -380,13 +402,13 @@ EXPORT int CALL InitiateAudio( AUDIO_INFO Audio_Info )
static int underrun_count = 0;
#ifdef USE_SRC
-float *_src = 0;
-unsigned int _src_len = 0;
-float *_dest = 0;
-unsigned int _dest_len = 0;
-int error;
-SRC_STATE *src_state;
-SRC_DATA src_data;
+static float *_src = NULL;
+static unsigned int _src_len = 0;
+static float *_dest = NULL;
+static unsigned int _dest_len = 0;
+static int error;
+static SRC_STATE *src_state;
+static SRC_DATA src_data;
#endif
static int resample(unsigned char *input, int input_avail, int oldsamplerate, unsigned char *output, int output_needed, int newsamplerate)
@@ -510,7 +532,7 @@ static void my_audio_callback(void *userdata, unsigned char *stream, int len)
memset(stream , 0, len);
}
}
-EXPORT int CALL RomOpen()
+EXPORT int CALL RomOpen(void)
{
if (!l_PluginInit)
return 0;
@@ -520,7 +542,7 @@ EXPORT int CALL RomOpen()
return 1;
}
-static void InitializeSDL()
+static void InitializeSDL(void)
{
DebugMessage(M64MSG_INFO, "Initializing SDL audio subsystem...");
@@ -700,7 +722,7 @@ EXPORT void CALL RomClosed( void )
if(SDL_WasInit(SDL_INIT_TIMER) != 0) SDL_QuitSubSystem(SDL_INIT_TIMER);
}
-EXPORT void CALL ProcessAList()
+EXPORT void CALL ProcessAList(void)
{
}
@@ -714,7 +736,7 @@ EXPORT void CALL SetSpeedFactor(int percentage)
CreatePrimaryBuffer();
}
-static void ReadConfig()
+static void ReadConfig(void)
{
/* read the configuration values into our static variables */
GameFreq = ConfigGetParamInt(l_ConfigAudio, "DEFAULT_FREQUENCY");
diff --git a/src/main.h b/src/main.h
index 96207cb..f29670f 100644
--- a/src/main.h
+++ b/src/main.h
@@ -21,6 +21,10 @@
/* version info */
#define SDL_AUDIO_PLUGIN_VERSION 0x016304
+#define AUDIO_PLUGIN_API_VERSION 0x020000
+#define CONFIG_API_VERSION 0x020000
+
+#define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff)
/* declarations of pointers to Core config functions */
extern ptr_ConfigListSections ConfigListSections;
diff --git a/src/osal_preproc.h b/src/osal_preproc.h
index 26e724d..a2e334e 100644
--- a/src/osal_preproc.h
+++ b/src/osal_preproc.h
@@ -29,4 +29,4 @@
#define HAS_OSS_SUPPORT
#endif
-#endif // OSAL_PREPROC_H
\ No newline at end of file
+#endif // OSAL_PREPROC_H
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-audio-sdl.git
More information about the Pkg-games-commits
mailing list