-
Notifications
You must be signed in to change notification settings - Fork 0
/
callbacks.c
28 lines (23 loc) · 1.12 KB
/
callbacks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "bass.h"
#include "_cgo_export.h"
#include <stdlib.h>
extern CALLBACK BOOL _GoBassRecordCallbackStreamPutData(DWORD recorder, const void* buffer, DWORD length, void* userdata) {
DWORD stream = (DWORD)(userdata);BASS_StreamPutData(stream, buffer, length);
return 1;
}
extern CALLBACK void _GoSyncprocCallbackWrapper(HSYNC sync, HCHANNEL channel, DWORD data, void* userdata) {
_GoSyncprocCallback(sync, channel, data, userdata);
}
// if we just try to get pointers to the above functions from Go, Go will get t the wrong names for these functions as they're __stdcall on 32-bit systems, which means a different naming convension, and Go won't pick up on that. Hello, linker errors. So we need to make wrapper functions which return the right function pointers and do it that way.
RECORDPROC* _get_GoBassRecordCallbackStreamPutData() {
return _GoBassRecordCallbackStreamPutData;
}
SYNCPROC* _get_GoSyncprocCallbackWrapper() {
return _GoSyncprocCallbackWrapper;
}
extern CALLBACK void _SyncprocFree(HSYNC sync, HCHANNEL channel, DWORD data, void* userdata) {
free(userdata);
}
SYNCPROC* _get_SyncprocFree() {
return _SyncprocFree;
}