From 6c2f2d925d579b92f752cf041e115c287df421e9 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 5 Feb 2016 02:08:15 +0000 Subject: [PATCH] plugin radio button coming up git-svn-id: https://svn.code.sf.net/p/freetel/code@2683 01035d8c-6547-0410-b346-abe4f91aad63 --- freedv-dev/src/fdmdv2_main.cpp | 145 ++++++++++++++++----------------- freedv-dev/src/fdmdv2_main.h | 20 ++--- freedv-dev/src/topFrame.cpp | 10 ++- freedv-dev/src/topFrame.h | 3 +- 4 files changed, 91 insertions(+), 87 deletions(-) diff --git a/freedv-dev/src/fdmdv2_main.cpp b/freedv-dev/src/fdmdv2_main.cpp index 051a67cb..50f48a47 100644 --- a/freedv-dev/src/fdmdv2_main.cpp +++ b/freedv-dev/src/fdmdv2_main.cpp @@ -165,18 +165,75 @@ bool MainApp::OnInit() m_textVoiceOutput.Empty(); m_strSampleRate.Empty(); m_strBitrate.Empty(); + + // 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) { + 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]; + m_plugIn = true; + (plugin_namefp)(s); + fprintf(stderr, "plugin name: %s\n", s); + m_plugInName = s; + + char param_name1[80], param_name2[80]; + char *param_names[2] = {param_name1, param_name2}; + int nparams, i; + m_plugInStates = (plugin_openfp)(param_names, &nparams); + m_numPlugInParam = nparams; + for(i=0; iRead(configStr, wxT("")); + } + } + + else { + fprintf(stderr, "plugin: fps not found...\n"); + } + } + else { + fprintf(stderr, "plugin not found...\n"); + } + // Create the main application window - frame = new MainFrame(NULL); + + frame = new MainFrame(m_plugInName, NULL); SetTopWindow(frame); + // Should guarantee that the first plot tab defined is the one // displayed. But it doesn't when built from command line. Why? + frame->m_auiNbookCtrl->ChangeSelection(0); frame->Layout(); frame->Show(); g_parent =frame; - //ft = fopen("tmp.raw","wb"); - //assert(ft != NULL); return true; } @@ -186,13 +243,21 @@ bool MainApp::OnInit() //------------------------------------------------------------------------- int MainApp::OnExit() { + if (m_plugIn) { + #ifdef __WXMSW__ + FreeLibrary((HMODULE)m_plugInHandle); + #else + dlclose(m_plugInHandle); + #endif + } + return 0; } //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= // Class MainFrame(wxFrame* pa->ent) : TopFrame(parent) //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-= -MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) +MainFrame::MainFrame(wxString plugInName, wxWindow *parent) : TopFrame(plugInName, parent) { m_zoom = 1.; @@ -525,66 +590,6 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) vk_state = VK_IDLE; - // 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) { - 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]; - m_plugIn = true; - (plugin_namefp)(s); - fprintf(stderr, "plugin name: %s\n", s); - m_plugInName = s; - - char param_name1[80], param_name2[80]; - char *param_names[2] = {param_name1, param_name2}; - int nparams, i; - m_plugInStates = (plugin_openfp)(param_names, &nparams); - m_numPlugInParam = nparams; - for(i=0; iRead(configStr, wxT("")); - } - } - - else { - fprintf(stderr, "plugin: fps not found...\n"); - } - } - else { - fprintf(stderr, "plugin not found...\n"); - } - - //m_plugIn = true; - //m_plugInName = "MyModem"; - //m_numPlugInParam = 2; - //m_plugInParamName[0] = "Symbol Rate"; - //m_plugInParamName[1] = "Num Tones"; } //------------------------------------------------------------------------- @@ -597,14 +602,6 @@ MainFrame::~MainFrame() int w; int h; - if (m_plugIn) { - #ifdef __WXMSW__ - FreeLibrary((HMODULE)m_plugInHandle); - #else - dlclose(m_plugInHandle); - #endif - } - //fclose(ft); #ifdef __WXMSW__ fclose(g_logfile); @@ -2236,14 +2233,14 @@ void MainFrame::OnToolsComCfgUI(wxUpdateUIEvent& event) void MainFrame::OnToolsPlugInCfg(wxCommandEvent& event) { wxUnusedVar(event); - PlugInDlg *dlg = new PlugInDlg(m_plugInName, m_numPlugInParam, m_plugInParamName); + PlugInDlg *dlg = new PlugInDlg(wxGetApp().m_plugInName, wxGetApp().m_numPlugInParam, wxGetApp().m_plugInParamName); dlg->ShowModal(); delete dlg; } void MainFrame::OnToolsPlugInCfgUI(wxUpdateUIEvent& event) { - event.Enable(!m_RxRunning && m_plugIn); + event.Enable(!m_RxRunning && wxGetApp().m_plugIn); } diff --git a/freedv-dev/src/fdmdv2_main.h b/freedv-dev/src/fdmdv2_main.h index 09657631..aedcf783 100644 --- a/freedv-dev/src/fdmdv2_main.h +++ b/freedv-dev/src/fdmdv2_main.h @@ -274,6 +274,15 @@ class MainApp : public wxApp wxString m_txtPlugInParam[PLUGIN_MAX_PARAMS]; + // plugin details + + void *m_plugInHandle; + bool m_plugIn; + wxString m_plugInName; + int m_numPlugInParam; + wxString m_plugInParamName[PLUGIN_MAX_PARAMS]; + void *m_plugInStates; + // misc bool m_testFrames; @@ -385,7 +394,7 @@ class UDPThread; class MainFrame : public TopFrame { public: - MainFrame(wxWindow *parent); + MainFrame(wxString plugInName, wxWindow *parent); virtual ~MainFrame(); PlotSpectrum* m_panelSpectrum; @@ -579,15 +588,6 @@ class MainFrame : public TopFrame int vk_rx_pause; int vk_repeats, vk_repeat_counter; float vk_rx_time; - - // plugin details - - void *m_plugInHandle; - bool m_plugIn; - wxString m_plugInName; - int m_numPlugInParam; - wxString m_plugInParamName[PLUGIN_MAX_PARAMS]; - void *m_plugInStates; }; void txRxProcessing(); diff --git a/freedv-dev/src/topFrame.cpp b/freedv-dev/src/topFrame.cpp index 0e228bab..7d1ee8a8 100644 --- a/freedv-dev/src/topFrame.cpp +++ b/freedv-dev/src/topFrame.cpp @@ -28,7 +28,7 @@ extern int g_playFileFromRadioEventId; //========================================================================= // Code that lays out the main application window //========================================================================= -TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) +TopFrame::TopFrame(wxString plugInName, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) { this->SetSizeHints(wxDefaultSize, wxDefaultSize); this->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); @@ -69,7 +69,7 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const tools->Append(m_menuItemFilter); wxMenuItem* m_menuItemPlugIn; - m_menuItemPlugIn = new wxMenuItem(tools, wxID_ANY, wxString(_("PlugIn Config")) , wxEmptyString, wxITEM_NORMAL); + m_menuItemPlugIn = new wxMenuItem(tools, wxID_ANY, plugInName + wxString(_(" Config")) , wxEmptyString, wxITEM_NORMAL); tools->Append(m_menuItemPlugIn); wxMenuItem* m_menuItemPlayFileToMicIn; @@ -317,6 +317,12 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const m_rb1600 = new wxRadioButton( this, wxID_ANY, wxT("1600"), wxDefaultPosition, wxDefaultSize, 0); sbSizer_mode->Add(m_rb1600, 0, wxALIGN_LEFT|wxALL, 1); m_rb1600->SetValue(true); + + // Optional plug in + + m_rbPlugIn = new wxRadioButton( this, wxID_ANY, plugInName, wxDefaultPosition, wxDefaultSize, 0); + sbSizer_mode->Add(m_rbPlugIn, 0, wxALIGN_LEFT|wxALL, 1); + #ifdef DISABLED_FEATURE m_rb1600Wide = new wxRadioButton( this, wxID_ANY, wxT("1600 Wide"), wxDefaultPosition, wxDefaultSize, 0); sbSizer_mode->Add(m_rb1600Wide, 0, wxALIGN_LEFT|wxALL, 1); diff --git a/freedv-dev/src/topFrame.h b/freedv-dev/src/topFrame.h index 3ed13a9c..07b7c152 100644 --- a/freedv-dev/src/topFrame.h +++ b/freedv-dev/src/topFrame.h @@ -111,6 +111,7 @@ class TopFrame : public wxFrame wxRadioButton *m_rb1600; wxRadioButton *m_rb2000; wxRadioButton *m_rb1600Wide; + wxRadioButton *m_rbPlugIn; // Virtual event handlers, overide them in your derived class virtual void topFrame_OnClose( wxCloseEvent& event ) { event.Skip(); } @@ -182,7 +183,7 @@ class TopFrame : public wxFrame wxToggleButton* m_togBtnLoopTx; wxAuiNotebook* m_auiNbookCtrl; - TopFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("FreeDV ") + _(FREEDV_VERSION), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(561,300 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + TopFrame( wxString plugInName, wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("FreeDV ") + _(FREEDV_VERSION), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(561,300 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); ~TopFrame(); }; -- 2.25.1