plugin radio button coming up
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 5 Feb 2016 02:08:15 +0000 (02:08 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 5 Feb 2016 02:08:15 +0000 (02:08 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2683 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/fdmdv2_main.h
freedv-dev/src/topFrame.cpp
freedv-dev/src/topFrame.h

index 051a67cb68d55a93d0a2c6970b6190745de15a7c..50f48a47ec0137b3191648cb63e937f1a1cad162 100644 (file)
@@ -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; i<nparams; i++) {
+                fprintf(stderr, "  plugin param name[%d]: %s\n", i, param_names[i]);
+                m_plugInParamName[i] = param_names[i];
+                wxString configStr = "/" + m_plugInName + "/" + m_plugInParamName[i];
+                m_txtPlugInParam[i] = pConfig->Read(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; i<nparams; i++) {
-                fprintf(stderr, "  plugin param name[%d]: %s\n", i, param_names[i]);
-                m_plugInParamName[i] = param_names[i];
-                wxString configStr = "/" + m_plugInName + "/" + m_plugInParamName[i];
-                wxGetApp().m_txtPlugInParam[i] = pConfig->Read(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);
 }
 
 
index 096576311967caa6ac124fbaf7aa39bfc9512856..aedcf7838d2e70c563f89731296caf48cdc12c2e 100644 (file)
@@ -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();
index 0e228bab9e7de981783300facb9af9ce22287acd..7d1ee8a831fc6f4cbab0da25d91209056d281982 100644 (file)
@@ -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);
index 3ed13a9c8d083bddb83fc030482a250f39f69379..07b7c152a45d3cbf13d441123cb2914e8c6f96af 100644 (file)
@@ -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();
 };