[ ] where do we put plugins?
[ ] Windows build and test environment
- $ gcc -Wall -fPIC -c afreedvplugin.c
- $ gcc -shared -Wl,-soname,afreedvplugin.so -o afreedvplugin.so afreedvplugin.o
+ linux .so:
+ $ gcc -Wall -fPIC -c afreedvplugin.c
+ $ gcc -shared -Wl,-soname,afreedvplugin.so -o afreedvplugin.so afreedvplugin.o
+ win32 .dll:
+ $ i686-w64-mingw32-gcc -c afreedvplugin.c
+ $ i686-w64-mingw32-gcc -shared -o afreedvplugin.dll afreedvplugin.o -Wl,--out-implib,afreedvplugin_dll.a
+
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-/* functions plugin can call */
+#ifdef _WIN32_
+#define DLL __declspec(dllexport)
+#else
+#define DLL
+#endif
+
+
+#ifdef LATER
+/* functions plugin can call - not sure how to link to these */
int plugin_alert(char string[]);
int plugin_get_persistant(char name[], char value[]);
int plugin_set_persistant(char name[], char value[]);
+#endif
struct APLUGIN_STATES {
int counter;
/* plugin functions called by host, we need to write these */
-void plugin_name(char name[]) {
+void DLL plugin_name(char name[]) {
sprintf(name, "aFreeDVplugIn");
}
storage as name/param_names[0], name/param_names[1] ....
*/
-void *plugin_open(char *param_names[], int *nparams) {
+void DLL *plugin_open(char *param_names[], int *nparams) {
struct APLUGIN_STATES *states;
strcpy(param_names[0], "SymbolRate");
states = (struct APLUGIN_STATES *)malloc(sizeof(struct APLUGIN_STATES));
if (states == NULL) {
- plugin_alert("Problem starting plugin!");
+ // TODO: plugin_alert("Problem starting plugin!");
return NULL;
}
states->counter = 0;
return (void*)states;
}
-void plugin_close(void *states) {
+void DLL plugin_close(void *states) {
free(states);
}
-void plugin_start(void *states) {
+void DLL plugin_start(void *states) {
}
-void plugin_stop(void *states) {
+void DLL plugin_stop(void *states) {
}
-void plugin_rx_samples(void *s, short samples[], int n) {
+void DLL plugin_rx_samples(void *s, short samples[], int n) {
struct APLUGIN_STATES *states = (struct APLUGIN_STATES*)s;
printf("Got n=%d samples!\n", n);
printf("samples[0] = %d samples[%d-1] = %d counter = %d\n", samples[0], n, samples[n-1], states->counter++);
// Look for Plug In
m_plugIn = false;
+ #ifdef __WXMSW__
+ wchar_t dll_path[] = L"/home/david/tmp/modem_api/afreedvplugin.dll";
+ m_plugInHandle = LoadLibrary(dll_path);
+ #else
m_plugInHandle = dlopen("/home/david/tmp/modem_api/afreedvplugin.so", RTLD_LAZY);
+ #endif
if (m_plugInHandle) {
- fprintf(stderr, "plugin: .so found\n");
-
+ printf("plugin: .so found\n");
+
// lets get some information abt the plugIn
void (*plugin_namefp)(char s[]);
void *(*plugin_openfp)(char *param_names[], int *nparams);
+ #ifdef __WXMSW__
+ plugin_namefp = (void (*)(char*))GetProcAddress((HMODULE)m_plugInHandle, "plugin_name");
+ plugin_openfp = (void* (*)(char**,int *))GetProcAddress((HMODULE)m_plugInHandle, "plugin_open");
+ #else
plugin_namefp = (void (*)(char*))dlsym(m_plugInHandle, "plugin_name");
plugin_openfp = (void* (*)(char**,int *))dlsym(m_plugInHandle, "plugin_open");
-
+ #endif
+
if ((plugin_namefp != NULL) && (plugin_openfp != NULL)) {
char s[256];
wxGetApp().m_txtPlugInParam[i] = pConfig->Read(configStr, wxT(""));
}
}
+
else {
- fprintf(stderr, "plugin: fps not found...\n");
+ fprintf(stderr, "plugin: fps not found...\n");
}
}
+ else {
+ fprintf(stderr, "plugin not found...\n");
+ }
//m_plugIn = true;
//m_plugInName = "MyModem";
int w;
int h;
- if (m_plugIn)
+ if (m_plugIn) {
+ #ifdef __WXMSW__
+ FreeLibrary((HMODULE)m_plugInHandle);
+ #else
dlclose(m_plugInHandle);
+ #endif
+ }
//fclose(ft);
#ifdef __WXMSW__