# HG changeset patch # User nemo # Date 1246199846 0 # Node ID 8192be6e3aef7f02638f49a57c3eca531f934341 # Parent be265856322fe0818cd3645171af8455f2acb3c8 koda/Smaxx changes to openal for crossplatform building diff -r be265856322f -r 8192be6e3aef CMakeLists.txt --- a/CMakeLists.txt Sat Jun 27 09:51:15 2009 +0000 +++ b/CMakeLists.txt Sun Jun 28 14:37:26 2009 +0000 @@ -22,7 +22,6 @@ set(universal_build "1") message("-- Building a Universal Application") endif(CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc7400" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc7400;i386" OR CMAKE_OSX_ARCHITECTURES MATCHES "i386;ppc" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc;i386") - endif(APPLE) if(DEFINED DATA_INSTALL_DIR) @@ -60,7 +59,7 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "Hedgewars ${HEDGEWARS_VERSION}") if(WIN32 AND NOT UNIX) - set(CPACK_NSIS_DISPLAY_NAME "Hedgewars, a turn-based Worms-like strategy") + set(CPACK_NSIS_DISPLAY_NAME "Hedgewars, a free turn-based strategy game") set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/") set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/") set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com") diff -r be265856322f -r 8192be6e3aef QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Sat Jun 27 09:51:15 2009 +0000 +++ b/QTfrontend/CMakeLists.txt Sun Jun 28 14:37:26 2009 +0000 @@ -17,8 +17,6 @@ # Configure for SDL find_package(SDL REQUIRED) -find_package(OpenAL REQUIRED) -find_package(OggVorbis REQUIRED) include_directories(${SDL_INCLUDE_DIR}) @@ -166,18 +164,29 @@ ${hwfr_hdrs} ${hwfr_rez_src}) -find_library(OPENALBRIDGE_LIBRARY libopenalbridge.a PATH ${EXECUTABLE_OUTPUT_PATH} ) - set(HW_LINK_LIBS ${QT_LIBRARIES} ${SDL_LIBRARY} - ${OPENAL_LIBRARY} - ${OGG_LIBRARY} - ${VORBIS_LIBRARY} - ${VORBISFILE_LIBRARY} - ${OPENALBRIDGE_LIBRARY} + openalbridge ) +#since openalbridge is linked statically in human systems we need to explicitly link dependencies +if(UNIX) + set(HW_LINK_LIBS + ${OPENAL_LIBRARY} + ${OGG_LIBRARY} + ${VORBIS_LIBRARY} + ${HW_LINK_LIBS} + ) +if(NOT APPLE) + set(HW_LINK_LIBS + ${VORBISFILE_LIBRARY} + ${HW_LINK_LIBS} + ) +endif(NOT APPLE) +endif(UNIX) + + if(WIN32 AND NOT UNIX) if(NOT SDL_LIBRARY) set(HW_LINK_LIBS diff -r be265856322f -r 8192be6e3aef cmake_modules/FindOggVorbis.cmake --- a/cmake_modules/FindOggVorbis.cmake Sat Jun 27 09:51:15 2009 +0000 +++ b/cmake_modules/FindOggVorbis.cmake Sun Jun 28 14:37:26 2009 +0000 @@ -1,90 +1,23 @@ -# - Try to find the OggVorbis libraries -# Once done this will define -# -# OGGVORBIS_FOUND - system has OggVorbis -# OGGVORBIS_VERSION - set either to 1 or 2 -# OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory -# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis -# OGG_LIBRARY - The Ogg library -# VORBIS_LIBRARY - The Vorbis library -# VORBISFILE_LIBRARY - The VorbisFile library -# VORBISENC_LIBRARY - The VorbisEnc library +FIND_PATH(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) +FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h) + +FIND_LIBRARY(OGG_LIBRARY NAMES ogg) + +FIND_LIBRARY(VORBIS_LIBRARY NAMES vorbis) +FIND_LIBRARY(VORBISFILE_LIBRARY NAMES vorbisfile) -# Copyright (c) 2006, Richard Laerkaeng, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -include (CheckLibraryExists) +IF(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) + SET(OGGVORBIS_FOUND TRUE) + SET(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) + SET(OGGVORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR}) +ELSE(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) + SET(OGGVORBIS_FOUND FALSE) +ENDIF(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) -find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) -find_path(OGG_INCLUDE_DIR ogg/ogg.h) - -find_library(OGG_LIBRARY NAMES ogg) -find_library(VORBIS_LIBRARY NAMES vorbis) -find_library(VORBISFILE_LIBRARY NAMES vorbisfile) -find_library(VORBISENC_LIBRARY NAMES vorbisenc) - -mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR - OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) +IF(OGGVORBIS_FOUND) + MESSAGE(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") +ELSE(OGGVORBIS_FOUND) + MESSAGE(FATAL_ERROR "Could NOT find Ogg and/or Vorbis - Visit xiph.org for them") +ENDIF(OGGVORBIS_FOUND) -if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set(OGGVORBIS_FOUND TRUE) - - set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY}) - - set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) - check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) - - if (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 2) - else (HAVE_LIBVORBISENC2) - set (OGGVORBIS_VERSION 1) - endif (HAVE_LIBVORBISENC2) - -else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - set (OGGVORBIS_VERSION) - set(OGGVORBIS_FOUND FALSE) -endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) - - -if (OGGVORBIS_FOUND) - if (NOT OggVorbis_FIND_QUIETLY) - message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") - endif (NOT OggVorbis_FIND_QUIETLY) -else (OGGVORBIS_FOUND) - if (OggVorbis_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find OggVorbis libraries") - endif (OggVorbis_FIND_REQUIRED) - if (NOT OggVorbis_FIND_QUITELY) - message(STATUS "Could NOT find OggVorbis libraries") - endif (NOT OggVorbis_FIND_QUITELY) -endif (OGGVORBIS_FOUND) - -#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H) -#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG) -#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS) -#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE) -#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC) -#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) - -#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis found") -# set (VORBIS_LIBS "-lvorbis -logg") -# set (VORBISFILE_LIBS "-lvorbisfile") -# set (VORBISENC_LIBS "-lvorbisenc") -# set (OGGVORBIS_FOUND TRUE) -# if (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 2) -# else (HAVE_LIBVORBISENC2) -# set (HAVE_VORBIS 1) -# endif (HAVE_LIBVORBISENC2) -#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) -# message(STATUS "Ogg/Vorbis not found") -#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) - - diff -r be265856322f -r 8192be6e3aef hedgewars/CMakeLists.txt --- a/hedgewars/CMakeLists.txt Sat Jun 27 09:51:15 2009 +0000 +++ b/hedgewars/CMakeLists.txt Sun Jun 28 14:37:26 2009 +0000 @@ -69,33 +69,14 @@ FIND_PACKAGE(SDL) if (SDL_FOUND) - #removing previous version of library - exec_program(rm - ARGS -f ${EXECUTABLE_OUTPUT_PATH}/libSDLmain.a ${EXECUTABLE_OUTPUT_PATH}/SDLMain.o - OUTPUT_VARIABLE noout - RETURN_VALUE testnoexecstack - ) - - #get what architectures to build - if(universal_build MATCHES "1") - set (arch_to_build "-arch i386 -arch ppc7400") - else(universal_build MATCHES "1") - set (arch_to_build "") - endif(universal_build MATCHES "1") - #build, archive and make lib - exec_program(${CMAKE_C_COMPILER} - ARGS ${arch_to_build} -o ${EXECUTABLE_OUTPUT_PATH}/SDLMain.o -c ${hedgewars_SOURCE_DIR}/hedgewars/SDLMain.m -I ${SDL_INCLUDE_DIR} -O2 - OUTPUT_VARIABLE noout - ) - exec_program(${CMAKE_AR} - ARGS -rvu ${EXECUTABLE_OUTPUT_PATH}/libSDLmain.a ${EXECUTABLE_OUTPUT_PATH}/SDLMain.o - OUTPUT_VARIABLE noout - ) - exec_program(${CMAKE_RANLIB} - ARGS ${EXECUTABLE_OUTPUT_PATH}/libSDLmain.a - OUTPUT_VARIABLE noout - ) + set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) + include_directories(${SDL_INCLUDE_DIR}) + link_libraries(${SDL_LIBRARY}) + + add_library (SDLmain STATIC SDLMain.m) + set(engine_sources SDLmain ${engine_sources}) + else (SDL_FOUND) message(FATAL_ERROR "No SDL framework found!") endif (SDL_FOUND) @@ -128,7 +109,7 @@ COMMAND "${pascal_compiler}" ARGS ${pascal_compiler_flags} MAIN_DEPENDENCY ${hwengine_project} - DEPENDS ${engine_sources} + DEPENDS openalbridge ${engine_sources} ) ELSE(NOT APPLE OR NOT universal_build MATCHES "1") @@ -138,7 +119,7 @@ COMMAND "ppc386" ARGS ${pascal_compiler_flags} -ohwengine.386 MAIN_DEPENDENCY ${hwengine_project} - DEPENDS ${engine_sources} + DEPENDS openalbridge ${engine_sources} ) add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.386") @@ -146,7 +127,7 @@ COMMAND "ppcppc" ARGS ${pascal_compiler_flags} -ohwengine.ppc MAIN_DEPENDENCY ${hwengine_project} - DEPENDS ${engine_sources} + DEPENDS openalbridge ${engine_sources} ) add_custom_target(hwengine.ppc ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}.ppc") diff -r be265856322f -r 8192be6e3aef hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sat Jun 27 09:51:15 2009 +0000 +++ b/hedgewars/SDLh.pas Sun Jun 28 14:37:26 2009 +0000 @@ -36,15 +36,16 @@ {$PACKRECORDS C} {$IFDEF DARWIN} - {$PASCALMAINNAME SDL_main} + {$PASCALMAINNAME SDL_main} {$IFNDEF IPHONEOS} - {$linkframework Cocoa} - {$linkframework SDL} - {$linkframework SDL_net} - {$linkframework SDL_image} - {$linkframework SDL_ttf} - {$linklib SDLmain} - {$linklib gcc} + {$linkframework Cocoa} + {$linkframework SDL} + {$linkframework SDL_net} + {$linkframework SDL_image} + {$linkframework SDL_ttf} + {$linklib openalbridge} + {$linklib SDLmain} + {$linklib gcc} {$ENDIF} {$ENDIF} diff -r be265856322f -r 8192be6e3aef hedgewars/uSound.pas --- a/hedgewars/uSound.pas Sat Jun 27 09:51:15 2009 +0000 +++ b/hedgewars/uSound.pas Sun Jun 28 14:37:26 2009 +0000 @@ -19,17 +19,20 @@ unit uSound; interface + {$IFDEF DARWIN} + {$linklib openalbridge} {$linkframework OpenAL} {$linkframework Ogg} {$linkframework Vorbis} - {$linklib openalbridge} {$ELSE} +{$IFDEF UNIX} {$linklib openal} {$linklib ogg} {$linklib vorbis} {$linklib vorbisfile} {$ENDIF} +{$ENDIF} uses uConsts; {$INCLUDE options.inc} @@ -40,7 +43,7 @@ chunks: array [TSound] of LongInt; end; -const OpenALBridge = 'libopenalbridge'; +const OpenALBridge = 'openalbridge'; procedure InitSound; procedure ReleaseSound; diff -r be265856322f -r 8192be6e3aef openalbridge/CMakeLists.txt --- a/openalbridge/CMakeLists.txt Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/CMakeLists.txt Sun Jun 28 14:37:26 2009 +0000 @@ -1,31 +1,36 @@ find_package(OpenAL REQUIRED) +find_package(OggVorbis REQUIRED) include_directories(${OPENAL_INCLUDE_DIR}) +include_directories(${OGGVORBIS_INCLUDE_DIRS}) -#add_library (openalbridge openalwrap.c loaders.c endianness.c wrappers.c) -exec_program(${CMAKE_C_COMPILER} - ARGS ${arch_to_build} -o ${EXECUTABLE_OUTPUT_PATH}/loaders.o -c ${hedgewars_SOURCE_DIR}/openalbridge/loaders.c -I ${OPENAL_INCLUDE_DIR} -O2 -w - OUTPUT_VARIABLE noout -) -exec_program(${CMAKE_C_COMPILER} - ARGS ${arch_to_build} -o ${EXECUTABLE_OUTPUT_PATH}/endianness.o -c ${hedgewars_SOURCE_DIR}/openalbridge/endianness.c -I ${OPENAL_INCLUDE_DIR} -O2 -w - OUTPUT_VARIABLE noout + +set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) +set(openal_src + openalwrap.c loaders.c endianness.c wrappers.c ) -exec_program(${CMAKE_C_COMPILER} - ARGS ${arch_to_build} -o ${EXECUTABLE_OUTPUT_PATH}/openalwrap.o -c ${hedgewars_SOURCE_DIR}/openalbridge/openalwrap.c -I ${OPENAL_INCLUDE_DIR} -O2 -w - OUTPUT_VARIABLE noout -) +#build a static library for human systems +set (build_type STATIC) + -exec_program(${CMAKE_C_COMPILER} - ARGS ${arch_to_build} -o ${EXECUTABLE_OUTPUT_PATH}/wrappers.o -c ${hedgewars_SOURCE_DIR}/openalbridge/wrappers.c -I ${OPENAL_INCLUDE_DIR} -O2 -w - OUTPUT_VARIABLE noout - ) - exec_program(${CMAKE_AR} - ARGS -rvu ${EXECUTABLE_OUTPUT_PATH}/libopenalbridge.a ${EXECUTABLE_OUTPUT_PATH}/loaders.o ${EXECUTABLE_OUTPUT_PATH}/endianness.o ${EXECUTABLE_OUTPUT_PATH}/openalwrap.o ${EXECUTABLE_OUTPUT_PATH}/wrappers.o - OUTPUT_VARIABLE noout - ) - exec_program(${CMAKE_RANLIB} - ARGS ${EXECUTABLE_OUTPUT_PATH}/libopenalbridge.a - OUTPUT_VARIABLE noout - ) +if(WIN32) +#workaround for visualstudio + set(openal_src + openalwrap.h loaders.h endianness.h wrappers.h winstdint.h ${openal_src} + ) +#deps for the shared library + link_libraries(${OPENAL_LIBRARY}) + link_libraries(${OGG_LIBRARY}) + link_libraries(${VORBIS_LIBRARY}) + link_libraries(${VORBISFILE_LIBRARY}) +#build a shared library + set (build_type SHARED) +endif(WIN32) +add_library (openalbridge ${build_type} ${openal_src}) + +if(WIN32) + SET_TARGET_PROPERTIES(openalbridge PROPERTIES LINK_FLAGS /DEF:openalbridge.def) +#install it in the executable directory + install(TARGETS openalbridge DESTINATION bin) +endif(WIN32) diff -r be265856322f -r 8192be6e3aef openalbridge/endianness.c --- a/openalbridge/endianness.c Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/endianness.c Sun Jun 28 14:37:26 2009 +0000 @@ -16,9 +16,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include -#include -#include #include "endianness.h" #ifdef __CPLUSPLUS diff -r be265856322f -r 8192be6e3aef openalbridge/endianness.h --- a/openalbridge/endianness.h Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/endianness.h Sun Jun 28 14:37:26 2009 +0000 @@ -16,6 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include +#include + +#ifndef _WIN32 +#include +#else +#include "winstdint.h" +#endif + #ifdef __CPLUSPLUS extern "C" { #endif diff -r be265856322f -r 8192be6e3aef openalbridge/loaders.c --- a/openalbridge/loaders.c Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/loaders.c Sun Jun 28 14:37:26 2009 +0000 @@ -16,14 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#include -#include -#include -#include "al.h" -#include "alc.h" #include "loaders.h" -#include "endianness.h" -#include "wrappers.h" #ifdef __CPLUSPLUS extern "C" { diff -r be265856322f -r 8192be6e3aef openalbridge/loaders.h --- a/openalbridge/loaders.h Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/loaders.h Sun Jun 28 14:37:26 2009 +0000 @@ -15,6 +15,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include +#include +#include "al.h" +#include "alc.h" +#include "endianness.h" +#include "wrappers.h" + +#ifndef _WIN32 +#include +#else +#include "winstdint.h" +#endif #ifdef __CPLUSPLUS extern "C" { diff -r be265856322f -r 8192be6e3aef openalbridge/openalwrap.c --- a/openalbridge/openalwrap.c Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/openalwrap.c Sun Jun 28 14:37:26 2009 +0000 @@ -72,7 +72,6 @@ /* This function initializes an OpenAL contex, allocates memory space for data and prepares OpenAL buffers*/ ALCcontext *context; ALCdevice *device; - ALenum error; const ALCchar *default_device; // Position of the listener. @@ -87,7 +86,7 @@ fprintf(stderr, "Using default device: %s\n", default_device); if ((device = alcOpenDevice(default_device)) == NULL) { - fprintf(stderr, "ERROR %d: Failed to open sound device\n", error); + fprintf(stderr, "ERROR: Failed to open sound device\n"); return AL_FALSE; } context = alcCreateContext(device, NULL); @@ -273,9 +272,9 @@ } #ifndef _WIN32 - void *helper_fadeout(void* tmp) { + void *helper_fadeout(void *tmp) { #else - VOID WINAPI helper_fadeout(LPVOID tmp) { + void WINAPI helper_fadeout(void *tmp) { #endif ALfloat gain; fade_t *fade; @@ -305,33 +304,36 @@ #ifndef _WIN32 pthread_exit(NULL); #else - ThreadExit(); + free(fade); + _endthread(); #endif } ALint openal_fadeout(int index, unsigned int quantity) { #ifndef _WIN32 pthread_t thread; + fade_t fade; + fade.index = index; + fade.quantity = quantity; #else HANDLE Thread; DWORD threadID; + fade_t *fade = malloc(sizeof(fade_t)); + fade->index = index; + fade->quantity = quantity; #endif - fade_t fade; - + if (index >= globalindex) { fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex); return AL_FALSE; } - fade.index = index; - fade.quantity = quantity; #ifndef _WIN32 pthread_create(&thread, NULL, helper_fadeout, (void*) &fade); pthread_detach(thread); #else - Thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) helper_fadeout, (void*) &fade, 0, threadID); - CloseHandle(Thread); + Thread = _beginthread(&helper_fadeout, 0, (void*) fade); #endif alGetError(); /* clear any AL errors beforehand */ @@ -340,9 +342,9 @@ } #ifndef _WIN32 - void *helper_fadein(void* tmp) + void *helper_fadein(void *tmp) #else - VOID WINAPI helper_fadein(LPVOID tmp) + void WINAPI helper_fadein(void *tmp) #endif { ALfloat gain; @@ -372,7 +374,8 @@ #ifndef _WIN32 pthread_exit(NULL); #else - ThreadExit(); + free(fade); + _endthread(); #endif } @@ -380,26 +383,27 @@ ALint openal_fadein(int index, unsigned int quantity) { #ifndef _WIN32 pthread_t thread; + fade_t fade; + fade.index = index; + fade.quantity = quantity; #else HANDLE Thread; DWORD threadID; + fade_t *fade = malloc(sizeof(fade_t)); + fade->index = index; + fade->quantity = quantity; #endif - fade_t fade; if (index >= globalindex) { fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex); return AL_FALSE; } - - fade.index = index; - fade.quantity = quantity; - + #ifndef _WIN32 pthread_create(&thread, NULL, helper_fadein, (void*) &fade); pthread_detach(thread); #else - Thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) helper_fadein, (void*) &fade, 0, threadID); - CloseHandle(Thread); + Thread = _beginthread(&helper_fadein, 0, (void*) fade); #endif alGetError(); /* clear any AL errors beforehand */ diff -r be265856322f -r 8192be6e3aef openalbridge/openalwrap.h --- a/openalbridge/openalwrap.h Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/openalwrap.h Sun Jun 28 14:37:26 2009 +0000 @@ -18,7 +18,6 @@ #include #include -#include #include "al.h" #include "alc.h" #include "loaders.h" @@ -27,8 +26,11 @@ #ifndef _WIN32 #include +#include #else +#define WIN32_LEAN_AND_MEAN #include +#include "winstdint.h" #endif #ifndef _SLEEP_H diff -r be265856322f -r 8192be6e3aef openalbridge/winstdint.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/openalbridge/winstdint.h Sun Jun 28 14:37:26 2009 +0000 @@ -0,0 +1,494 @@ +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef char int8_t; + typedef short int16_t; + typedef int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef __int8 int8_t; + typedef __int16 int16_t; + typedef __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] +// ISO C9x compliant stdint.h for Microsoft Visual Studio +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// +// Copyright (c) 2006-2008 Alexander Chemeris +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// 3. The name of the author may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _MSC_VER // [ +#error "Use this header only with Microsoft Visual C++ compilers!" +#endif // _MSC_VER ] + +#ifndef _MSC_STDINT_H_ // [ +#define _MSC_STDINT_H_ + +#if _MSC_VER > 1000 +#pragma once +#endif + +#include + +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when +// compiling for ARM we should wrap include with 'extern "C++" {}' +// or compiler give many errors like this: +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed +#ifdef __cplusplus +extern "C" { +#endif +# include +#ifdef __cplusplus +} +#endif + +// Define _W64 macros to mark types changing their size, like intptr_t. +#ifndef _W64 +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +# define _W64 __w64 +# else +# define _W64 +# endif +#endif + + +// 7.18.1 Integer types + +// 7.18.1.1 Exact-width integer types + +// Visual Studio 6 and Embedded Visual C++ 4 doesn't +// realize that, e.g. char has the same size as __int8 +// so we give up on __intX for them. +#if (_MSC_VER < 1300) + typedef char int8_t; + typedef short int16_t; + typedef int int32_t; + typedef unsigned char uint8_t; + typedef unsigned short uint16_t; + typedef unsigned int uint32_t; +#else + typedef __int8 int8_t; + typedef __int16 int16_t; + typedef __int32 int32_t; + typedef unsigned __int8 uint8_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int32 uint32_t; +#endif +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; + + +// 7.18.1.2 Minimum-width integer types +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; + +// 7.18.1.3 Fastest minimum-width integer types +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; + +// 7.18.1.4 Integer types capable of holding object pointers +#ifdef _WIN64 // [ + typedef __int64 intptr_t; + typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ + typedef _W64 int intptr_t; + typedef _W64 unsigned int uintptr_t; +#endif // _WIN64 ] + +// 7.18.1.5 Greatest-width integer types +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; + + +// 7.18.2 Limits of specified-width integer types + +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 + +// 7.18.2.1 Limits of exact-width integer types +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX + +// 7.18.2.2 Limits of minimum-width integer types +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX + +// 7.18.2.3 Limits of fastest minimum-width integer types +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX + +// 7.18.2.4 Limits of integer types capable of holding object pointers +#ifdef _WIN64 // [ +# define INTPTR_MIN INT64_MIN +# define INTPTR_MAX INT64_MAX +# define UINTPTR_MAX UINT64_MAX +#else // _WIN64 ][ +# define INTPTR_MIN INT32_MIN +# define INTPTR_MAX INT32_MAX +# define UINTPTR_MAX UINT32_MAX +#endif // _WIN64 ] + +// 7.18.2.5 Limits of greatest-width integer types +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX + +// 7.18.3 Limits of other integer types + +#ifdef _WIN64 // [ +# define PTRDIFF_MIN _I64_MIN +# define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +# define PTRDIFF_MIN _I32_MIN +# define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] + +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX + +#ifndef SIZE_MAX // [ +# ifdef _WIN64 // [ +# define SIZE_MAX _UI64_MAX +# else // _WIN64 ][ +# define SIZE_MAX _UI32_MAX +# endif // _WIN64 ] +#endif // SIZE_MAX ] + +// WCHAR_MIN and WCHAR_MAX are also defined in +#ifndef WCHAR_MIN // [ +# define WCHAR_MIN 0 +#endif // WCHAR_MIN ] +#ifndef WCHAR_MAX // [ +# define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] + +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX + +#endif // __STDC_LIMIT_MACROS ] + + +// 7.18.4 Limits of other integer types + +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 + +// 7.18.4.1 Macros for minimum-width integer constants + +#define INT8_C(val) val##i8 +#define INT16_C(val) val##i16 +#define INT32_C(val) val##i32 +#define INT64_C(val) val##i64 + +#define UINT8_C(val) val##ui8 +#define UINT16_C(val) val##ui16 +#define UINT32_C(val) val##ui32 +#define UINT64_C(val) val##ui64 + +// 7.18.4.2 Macros for greatest-width integer constants +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C + +#endif // __STDC_CONSTANT_MACROS ] + + +#endif // _MSC_STDINT_H_ ] diff -r be265856322f -r 8192be6e3aef openalbridge/wrappers.c --- a/openalbridge/wrappers.c Sat Jun 27 09:51:15 2009 +0000 +++ b/openalbridge/wrappers.c Sun Jun 28 14:37:26 2009 +0000 @@ -25,8 +25,10 @@ void *Malloc (size_t nbytes) { void *aptr; - if ( (aptr = malloc(nbytes)) == NULL) + if ( (aptr = malloc(nbytes)) == NULL) { fprintf(stderr, "ERROR: not enough memory! malloc() failed"); + exit(-1); + } return aptr; }