GNU compilation of SoundTouchDll that has easy function importing interfaces for java, mono etc

This commit is contained in:
oparviai 2017-11-03 20:08:10 +00:00
parent 05a3403137
commit 407f516e0d
3 changed files with 59 additions and 34 deletions

View File

@ -34,18 +34,11 @@
// //
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(WIN32)
#include <windows.h> #include <windows.h>
#include <string.h>
#include "SoundTouchDLL.h"
#include "soundtouch.h"
using namespace soundtouch;
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
#error "error - compile the dll version with float samples"
#endif // SOUNDTOUCH_INTEGER_SAMPLES
// DLL main in Windows compilation
BOOL APIENTRY DllMain( HANDLE hModule, BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved LPVOID lpReserved
@ -61,7 +54,18 @@ BOOL APIENTRY DllMain( HANDLE hModule,
} }
return TRUE; return TRUE;
} }
#endif
#include <limits.h>
#include <string.h>
#include "SoundTouchDLL.h"
#include "SoundTouch.h"
using namespace soundtouch;
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
#error "error - compile the dll version with float samples"
#endif // SOUNDTOUCH_INTEGER_SAMPLES
////////////// //////////////

View File

@ -37,7 +37,11 @@
#ifndef _SoundTouchDLL_h_ #ifndef _SoundTouchDLL_h_
#define _SoundTouchDLL_h_ #define _SoundTouchDLL_h_
#ifdef __cplusplus #if defined(_WIN32) || defined(WIN32)
// Windows
#ifndef __cplusplus
#error "Expected g++"
#endif
#ifdef DLL_EXPORTS #ifdef DLL_EXPORTS
#define SOUNDTOUCHDLL_API extern "C" __declspec(dllexport) #define SOUNDTOUCHDLL_API extern "C" __declspec(dllexport)
@ -46,14 +50,23 @@
#endif #endif
#else #else
// GNU version
#ifdef DLL_EXPORTS #ifdef DLL_EXPORTS
#define SOUNDTOUCHDLL_API __declspec(dllexport) // GCC declaration for exporting functions
#define SOUNDTOUCHDLL_API extern "C" __attribute__((__visibility__("default")))
#else #else
#define SOUNDTOUCHDLL_API __declspec(dllimport) // GCC doesn't require DLL imports
#define SOUNDTOUCHDLL_API
#endif #endif
#endif // __cplusplus // Linux-replacements for Windows declarations:
#define __cdecl
typedef unsigned int DWORD;
#define FALSE 0
#define TRUE 1
#endif
typedef void * HANDLE; typedef void * HANDLE;

View File

@ -0,0 +1,8 @@
#!/bin/sh
#
# This script compiles SoundTouch dynamic-link library for GNU environment
# with wrapper functions that are easier to import to Java / Mono / etc
#
g++ -fPIC -shared -DDLL_EXPORTS -fvisibility=hidden -I../../include -o SoundTouchDll.so \
SoundTouchDLL.cpp ../SoundTouch/*.cpp -I../SoundTouch -O3 -msse