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,10 +34,32 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <windows.h>
#if defined(_WIN32) || defined(WIN32)
#include <windows.h>
// DLL main in Windows compilation
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#endif
#include <limits.h>
#include <string.h>
#include "SoundTouchDLL.h"
#include "soundtouch.h"
#include "SoundTouch.h"
using namespace soundtouch;
@ -45,24 +67,6 @@ using namespace soundtouch;
#error "error - compile the dll version with float samples"
#endif // SOUNDTOUCH_INTEGER_SAMPLES
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//////////////
typedef struct

View File

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

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