1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

ModuleManager doesn't specially start up mod-script-pipe...

... The standard module dispatch can do that.
This commit is contained in:
Paul Licameli 2020-11-14 09:34:30 -05:00
parent c7834257d8
commit bbda68c079
4 changed files with 18 additions and 39 deletions

View File

@ -39,10 +39,6 @@ There are several functions that can be used in a GUI module.
The most useful function. See the example in this The most useful function. See the example in this
file. It has several cases/options in it. file. It has several cases/options in it.
//#define scriptFnName "RegScriptServerFunc"
This function is run from a non gui thread. It was originally
created for the benefit of mod-script-pipe.
//#define mainPanelFnName "MainPanelFunc" //#define mainPanelFnName "MainPanelFunc"
This function is the hijacking function, to take over Audacity This function is the hijacking function, to take over Audacity
and replace the main project window with our own wxFrame. and replace the main project window with our own wxFrame.

View File

@ -96,10 +96,6 @@ There are several functions that can be used in a GUI module.
The most useful function. See the example in this The most useful function. See the example in this
file. It has several cases/options in it. file. It has several cases/options in it.
//#define scriptFnName "RegScriptServerFunc"
This function is run from a non gui thread. It was originally
created for the benefit of mod-script-pipe.
//#define mainPanelFnName "MainPanelFunc" //#define mainPanelFnName "MainPanelFunc"
This function is the hijacking function, to take over Audacity This function is the hijacking function, to take over Audacity
and replace the main project window with our own wxFrame. and replace the main project window with our own wxFrame.

View File

@ -15,6 +15,7 @@
#include <wx/wx.h> #include <wx/wx.h>
#include "ScripterCallback.h" #include "ScripterCallback.h"
#include "commands/ScriptCommandRelay.h"
/* /*
There are several functions that can be used in a GUI module. There are several functions that can be used in a GUI module.
@ -23,10 +24,6 @@ There are several functions that can be used in a GUI module.
The most useful function. See the example in this The most useful function. See the example in this
file. It has several cases/options in it. file. It has several cases/options in it.
//#define scriptFnName "RegScriptServerFunc"
This function is run from a non gui thread. It was originally
created for the benefit of mod-script-pipe.
//#define mainPanelFnName "MainPanelFunc" //#define mainPanelFnName "MainPanelFunc"
This function is the hijacking function, to take over Audacity This function is the hijacking function, to take over Audacity
and replace the main project window with our own wxFrame. and replace the main project window with our own wxFrame.
@ -40,8 +37,6 @@ typedef DLL_IMPORT int (*tpExecScriptServerFunc)( wxString * pIn, wxString * pOu
static tpExecScriptServerFunc pScriptServerFn=NULL; static tpExecScriptServerFunc pScriptServerFn=NULL;
DEFINE_MODULE_ENTRIES
extern "C" { extern "C" {
// And here is our special registration function. // And here is our special registration function.
@ -56,6 +51,18 @@ int DLL_API RegScriptServerFunc( tpExecScriptServerFunc pFn )
return 4; return 4;
} }
DEFINE_VERSION_CHECK
extern "C" DLL_API int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type) {
case ModuleInitialize:
ScriptCommandRelay::StartScriptServer(RegScriptServerFunc);
break;
default:
break;
}
return 1;
}
wxString Str2; wxString Str2;
wxArrayString aStr; wxArrayString aStr;

View File

@ -12,8 +12,8 @@
\file ModuleManager.cpp \file ModuleManager.cpp
\brief Based on LoadLadspa, this code loads pluggable Audacity \brief Based on LoadLadspa, this code loads pluggable Audacity
extension modules. It also has the code to (a) invoke a script extension modules. It also has the code to
server and (b) invoke a function returning a replacement window, invoke a function returning a replacement window,
i.e. an alternative to the usual interface, for Audacity. i.e. an alternative to the usual interface, for Audacity.
*//*******************************************************************/ *//*******************************************************************/
@ -32,8 +32,6 @@ i.e. an alternative to the usual interface, for Audacity.
#include "FileNames.h" #include "FileNames.h"
#include "PluginManager.h" #include "PluginManager.h"
#include "commands/ScriptCommandRelay.h"
#include "audacity/PluginInterface.h" #include "audacity/PluginInterface.h"
#ifdef EXPERIMENTAL_MODULE_PREFS #ifdef EXPERIMENTAL_MODULE_PREFS
@ -47,7 +45,6 @@ i.e. an alternative to the usual interface, for Audacity.
#define initFnName "ExtensionModuleInit" #define initFnName "ExtensionModuleInit"
#define versionFnName "GetVersionString" #define versionFnName "GetVersionString"
#define scriptFnName "RegScriptServerFunc"
#define mainPanelFnName "MainPanelFunc" #define mainPanelFnName "MainPanelFunc"
typedef wxWindow * pwxWindow; typedef wxWindow * pwxWindow;
@ -80,10 +77,6 @@ wxWindow * MakeHijackPanel()
return pPanelHijack(0); return pPanelHijack(0);
} }
// This variable will hold the address of a subroutine in a DLL that
// starts a thread and reads script commands.
static tpRegScriptServerFunc scriptFn;
Module::Module(const FilePath & name) Module::Module(const FilePath & name)
: mName{ name } : mName{ name }
{ {
@ -152,8 +145,7 @@ bool Module::Load(wxString &deferredErrorMessage)
mDispatch = (fnModuleDispatch) mLib->GetSymbol(wxT(ModuleDispatchName)); mDispatch = (fnModuleDispatch) mLib->GetSymbol(wxT(ModuleDispatchName));
if (!mDispatch) { if (!mDispatch) {
// Module does not provide a dispatch function. Special case modules like this could be: // Module does not provide a dispatch function. Special case modules like this could be:
// (a) for scripting (RegScriptServerFunc entry point) // (a) for hijacking the entire Audacity panel (MainPanelFunc entry point)
// (b) for hijacking the entire Audacity panel (MainPanelFunc entry point)
return true; return true;
} }
@ -353,20 +345,14 @@ void ModuleManager::TryLoadModules(
// So look for special case functions: // So look for special case functions:
wxLogNull logNo; // Don't show wxWidgets errors if we can't do these. (Was: Fix bug 544.) wxLogNull logNo; // Don't show wxWidgets errors if we can't do these. (Was: Fix bug 544.)
// (a) for scripting. // (a) for hijacking the entire Audacity panel.
if (scriptFn == NULL)
{
scriptFn = (tpRegScriptServerFunc)(module->GetSymbol(wxT(scriptFnName)));
}
// (b) for hijacking the entire Audacity panel.
if (pPanelHijack == NULL) if (pPanelHijack == NULL)
{ {
pPanelHijack = (tPanelFn)(module->GetSymbol(wxT(mainPanelFnName))); pPanelHijack = (tPanelFn)(module->GetSymbol(wxT(mainPanelFnName)));
} }
} }
if (!module->HasDispatch() && !scriptFn && !pPanelHijack) if (!module->HasDispatch() && !pPanelHijack)
{ {
auto ShortName = wxFileName(file).GetName(); auto ShortName = wxFileName(file).GetName();
AudacityMessageBox( AudacityMessageBox(
@ -420,12 +406,6 @@ void ModuleManager::Initialize()
pModule->ShowLoadFailureError(pair.second); pModule->ShowLoadFailureError(pair.second);
ModulePrefs::SetModuleStatus( pModule->GetName(), kModuleFailed ); ModulePrefs::SetModuleStatus( pModule->GetName(), kModuleFailed );
} }
// After loading all the modules, we may have a registered scripting function.
if(scriptFn)
{
ScriptCommandRelay::StartScriptServer(scriptFn);
}
} }
// static // static