295 lines
9.6 KiB
C
295 lines
9.6 KiB
C
|
/*
|
||
|
* bass_fx.dll
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include "bass_fx_dll.h"
|
||
|
|
||
|
#include <stdarg.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <pthread.h>
|
||
|
|
||
|
// WINE_DEFAULT_DEBUG_CHANNEL(bassfx);
|
||
|
|
||
|
#define BASSFX_STRINGIFY(S) #S
|
||
|
#define BASSFX_RETURN(X) {\
|
||
|
return X; \
|
||
|
}
|
||
|
|
||
|
static char FILEBUFFFF[256];
|
||
|
static char ZEROOOOOO = '\n';
|
||
|
static pthread_mutex_t FILE_MUTEXX;
|
||
|
static FILE *filkdwkowee;
|
||
|
|
||
|
// from bass.dll.so
|
||
|
typedef BOOL (__stdcall *wine_bass_user_data_add_ex_t)(DWORD key, DWORD altKey, void *val);
|
||
|
typedef void (__stdcall *wine_bass_user_data_remove_ex_t)(DWORD key, DWORD altKey);
|
||
|
static pthread_mutex_t WINE_BASSFX_FNS;
|
||
|
static wine_bass_user_data_add_ex_t WINE_BASSFX_ADD_EX;
|
||
|
static wine_bass_user_data_remove_ex_t WINE_BASSFX_REMOVE_EX;
|
||
|
|
||
|
static inline wine_bass_user_data_add_ex_t wine_bass_user_data_add_ex_get() {
|
||
|
// this is a potential data race, but I don't care
|
||
|
if (WINE_BASSFX_ADD_EX) return WINE_BASSFX_ADD_EX;
|
||
|
// pthread_mutex_lock(&WINE_BASSFX_FNS);
|
||
|
HMODULE handle = GetModuleHandleA("bass.dll");
|
||
|
wine_bass_user_data_add_ex_t ret = NULL;
|
||
|
if (handle) {
|
||
|
void *tmp = GetProcAddress(handle, "wine_bass_user_data_add_export");
|
||
|
if (!tmp) tmp = GetProcAddress(handle, "wine_bass_user_data_add_ex");
|
||
|
ret = tmp;
|
||
|
}
|
||
|
WINE_BASSFX_ADD_EX = ret;
|
||
|
// pthread_mutex_unlock(&WINE_BASSFX_FNS);
|
||
|
return ret;
|
||
|
}
|
||
|
static inline BOOL wine_bass_user_data_add_ex_try(DWORD key, DWORD altKey, void *val) {
|
||
|
wine_bass_user_data_add_ex_t ptr = NULL;
|
||
|
ptr = wine_bass_user_data_add_ex_get();
|
||
|
if (!ptr) return FALSE;
|
||
|
return ptr(key, altKey, val);
|
||
|
}
|
||
|
static inline wine_bass_user_data_remove_ex_t wine_bass_user_data_remove_ex_get() {
|
||
|
if (WINE_BASSFX_REMOVE_EX) return WINE_BASSFX_REMOVE_EX;
|
||
|
// pthread_mutex_lock(&WINE_BASSFX_FNS);
|
||
|
HMODULE handle = GetModuleHandleA("bass.dll");
|
||
|
wine_bass_user_data_remove_ex_t ret = NULL;
|
||
|
if (handle) {
|
||
|
void *tmp = GetProcAddress(handle, "wine_bass_user_data_remove_export");
|
||
|
if (!tmp) tmp = GetProcAddress(handle, "wine_bass_user_data_remove_ex");
|
||
|
ret = tmp;
|
||
|
}
|
||
|
WINE_BASSFX_REMOVE_EX = ret;
|
||
|
// pthread_mutex_unlock(&WINE_BASSFX_FNS);
|
||
|
return ret;
|
||
|
}
|
||
|
void wine_bass_user_data_remove_ex_try(DWORD key, DWORD altKey) {
|
||
|
wine_bass_user_data_remove_ex_t ptr = NULL;
|
||
|
ptr = wine_bass_user_data_remove_ex_get();
|
||
|
if (ptr) return ptr(key, altKey);
|
||
|
}
|
||
|
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatCallbackReset (BASS_FX.1)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatCallbackReset(DWORD handle) {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatCallbackReset(handle));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatCallbackSet (BASS_FX.2)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
typedef struct {
|
||
|
WIN_BPMBEATPROC *proc;
|
||
|
void *user;
|
||
|
} BpmBeatUserData;
|
||
|
|
||
|
void wine_bassfx_bpmbeatproc_wrapper(DWORD chan, double beatpos, void *user) {
|
||
|
BpmBeatUserData *user_new = user;
|
||
|
BASSFX_RETURN(user_new->proc(chan, beatpos, user_new->user));
|
||
|
}
|
||
|
|
||
|
void wine_bassfx_bpmbeatproc_wrapper_nouser(DWORD chan, double beatpos, void *user) {
|
||
|
WIN_BPMBEATPROC *proc = user;
|
||
|
BASSFX_RETURN(proc(chan, beatpos, NULL));
|
||
|
}
|
||
|
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatCallbackSet(DWORD handle, WIN_BPMBEATPROC * proc, void * user) {
|
||
|
if (user) {
|
||
|
BpmBeatUserData *user_new = malloc(sizeof(BpmBeatUserData));
|
||
|
user_new->proc = proc;
|
||
|
user_new->user = user;
|
||
|
BOOL ret = BASS_FX_BPM_BeatCallbackSet(handle, wine_bassfx_bpmbeatproc_wrapper, user_new);
|
||
|
if (ret) wine_bass_user_data_add_ex_try(handle, 0xB455F4, user_new);
|
||
|
else free(user_new);
|
||
|
return ret;
|
||
|
} else {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatCallbackSet(handle, wine_bassfx_bpmbeatproc_wrapper_nouser, proc));
|
||
|
}
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatDecodeGet (BASS_FX.3)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatDecodeGet(DWORD chan, double startSec, double endSec, DWORD flags, WIN_BPMBEATPROC * proc, void * user) {
|
||
|
if (user) {
|
||
|
BpmBeatUserData *user_new = malloc(sizeof(BpmBeatUserData));
|
||
|
user_new->proc = proc;
|
||
|
user_new->user = user;
|
||
|
BOOL ret = BASS_FX_BPM_BeatDecodeGet(chan, startSec, endSec, flags, wine_bassfx_bpmbeatproc_wrapper, user_new);
|
||
|
if (ret) wine_bass_user_data_add_ex_try(chan, 0xB455F4, user_new);
|
||
|
else free(user_new);
|
||
|
return ret;
|
||
|
} else {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatDecodeGet(chan, startSec, endSec, flags, wine_bassfx_bpmbeatproc_wrapper_nouser, proc));
|
||
|
}
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatFree (BASS_FX.4)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatFree(DWORD handle) {
|
||
|
wine_bass_user_data_remove_ex_try(handle, 0xB455F4);
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatFree(handle));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatGetParameters (BASS_FX.5)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatGetParameters(DWORD handle, float * bandwidth, float * centerfreq, float * beat_rtime) {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatGetParameters(handle, bandwidth, centerfreq, beat_rtime));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_BeatSetParameters (BASS_FX.6)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_BeatSetParameters(DWORD handle, float bandwidth, float centerfreq, float beat_rtime) {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_BeatSetParameters(handle, bandwidth, centerfreq, beat_rtime));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_CallbackReset (BASS_FX.7)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_CallbackReset(DWORD handle) {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_CallbackReset(handle));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_CallbackSet (BASS_FX.8)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
typedef struct {
|
||
|
WIN_BPMPROC *proc;
|
||
|
void *user;
|
||
|
} BpmUserData;
|
||
|
|
||
|
void wine_bassfx_bpmproc_wrapper(DWORD chan, float bpm, void *user) {
|
||
|
BpmUserData *user_new = user;
|
||
|
BASSFX_RETURN(user_new->proc(chan, bpm, user_new->user));
|
||
|
}
|
||
|
|
||
|
void wine_bassfx_bpmproc_wrapper_nouser(DWORD chan, float bpm, void *user) {
|
||
|
WIN_BPMPROC *proc = user;
|
||
|
BASSFX_RETURN(proc(chan, bpm, NULL));
|
||
|
}
|
||
|
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_CallbackSet(DWORD handle, WIN_BPMPROC * proc, double period, DWORD minMaxBPM, DWORD flags, void * user) {
|
||
|
if (user) {
|
||
|
BpmUserData *user_new = malloc(sizeof(BpmUserData));
|
||
|
user_new->proc = proc;
|
||
|
user_new->user = user;
|
||
|
BOOL ret = BASS_FX_BPM_CallbackSet(handle, wine_bassfx_bpmproc_wrapper, period, minMaxBPM, flags, user_new);
|
||
|
if (ret) wine_bass_user_data_add_ex_try(handle, 0xB455F2, user_new);
|
||
|
else free(user_new);
|
||
|
return ret;
|
||
|
} else {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_CallbackSet(handle, wine_bassfx_bpmproc_wrapper_nouser, period, minMaxBPM, flags, proc));
|
||
|
}
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_DecodeGet (BASS_FX.9)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
typedef struct {
|
||
|
WIN_BPMPROGRESSPROC *proc;
|
||
|
void *user;
|
||
|
} BpmProgressUserData;
|
||
|
|
||
|
void wine_bassfx_bpmprogressproc_wrapper(DWORD chan, float percent, void *user) {
|
||
|
BpmProgressUserData *user_new = user;
|
||
|
BASSFX_RETURN(user_new->proc(chan, percent, user_new->user));
|
||
|
}
|
||
|
|
||
|
void wine_bassfx_bpmprogressproc_wrapper_nouser(DWORD chan, float percent, void *user) {
|
||
|
WIN_BPMPROGRESSPROC *proc = user;
|
||
|
BASSFX_RETURN(proc(chan, percent, NULL));
|
||
|
}
|
||
|
|
||
|
float __stdcall BASS_FX_BASS_FX_BPM_DecodeGet(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, WIN_BPMPROGRESSPROC * proc, void * user) {
|
||
|
if (user) {
|
||
|
BpmProgressUserData *user_new = malloc(sizeof(BpmProgressUserData));
|
||
|
user_new->proc = proc;
|
||
|
user_new->user = user;
|
||
|
float ret = BASS_FX_BPM_DecodeGet(chan, startSec, endSec, minMaxBPM, flags, wine_bassfx_bpmprogressproc_wrapper, user_new);
|
||
|
if (ret > -0.1) wine_bass_user_data_add_ex_try(chan, 0xB455F2, user_new);
|
||
|
else free(user_new);
|
||
|
return ret;
|
||
|
} else {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_DecodeGet(chan, startSec, endSec, minMaxBPM, flags, wine_bassfx_bpmprogressproc_wrapper_nouser, proc));
|
||
|
}
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_Free (BASS_FX.10)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
BOOL __stdcall BASS_FX_BASS_FX_BPM_Free(DWORD handle) {
|
||
|
wine_bass_user_data_remove_ex_try(handle, 0xB455F2);
|
||
|
BASSFX_RETURN(BASS_FX_BPM_Free(handle));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_BPM_Translate (BASS_FX.11)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
float __stdcall BASS_FX_BASS_FX_BPM_Translate(DWORD handle, float val2tran, DWORD trans) {
|
||
|
BASSFX_RETURN(BASS_FX_BPM_Translate(handle, val2tran, trans));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_GetVersion (BASS_FX.12)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
DWORD __stdcall BASS_FX_BASS_FX_GetVersion(void) {
|
||
|
BASSFX_RETURN(BASS_FX_GetVersion());
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_ReverseCreate (BASS_FX.13)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
WIN_HSTREAM __stdcall BASS_FX_BASS_FX_ReverseCreate(DWORD chan, float dec_block, DWORD flags) {
|
||
|
BASSFX_RETURN(BASS_FX_ReverseCreate(chan, dec_block, flags));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_ReverseGetSource (BASS_FX.14)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
DWORD __stdcall BASS_FX_BASS_FX_ReverseGetSource(WIN_HSTREAM chan) {
|
||
|
BASSFX_RETURN(BASS_FX_ReverseGetSource(chan));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_TempoCreate (BASS_FX.15)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
WIN_HSTREAM __stdcall BASS_FX_BASS_FX_TempoCreate(DWORD chan, DWORD flags) {
|
||
|
BASSFX_RETURN(BASS_FX_TempoCreate(chan, flags));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_TempoGetRateRatio (BASS_FX.16)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
float __stdcall BASS_FX_BASS_FX_TempoGetRateRatio(WIN_HSTREAM chan) {
|
||
|
BASSFX_RETURN(BASS_FX_TempoGetRateRatio(chan));
|
||
|
}
|
||
|
/******************************************************************
|
||
|
* BASS_FX_TempoGetSource (BASS_FX.17)
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
DWORD __stdcall BASS_FX_BASS_FX_TempoGetSource(WIN_HSTREAM chan) {
|
||
|
BASSFX_RETURN(BASS_FX_TempoGetSource(chan));
|
||
|
}
|