Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule Class Reference
Inheritance diagram for VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule:
[legend]
Collaboration diagram for VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule:
[legend]

Public Member Functions

template<typename T >
getFunctionPointer (const char *name)
 
 ~LinuxModule () override
 
bool load (const std::string &inPath, std::string &errorDescription) override
 
- Public Member Functions inherited from Module
 Module (const FilePath &name)
 
virtual ~Module ()
 
void ShowLoadFailureError (const wxString &Error)
 
bool Load (wxString &deferredErrorMessage)
 
void Unload ()
 
bool HasDispatch ()
 
int Dispatch (ModuleDispatchTypes type)
 
void * GetSymbol (const wxString &name)
 
const FilePathGetName () const
 

Static Public Member Functions

static Optional< PathgetSOPath (const std::string &inPath)
 

Public Attributes

void * mModule {nullptr}
 

Detailed Description

Definition at line 116 of file module_linux.cpp.

Constructor & Destructor Documentation

◆ ~LinuxModule()

VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule::~LinuxModule ( )
inlineoverride

Definition at line 125 of file module_linux.cpp.

126 {
127 factory = PluginFactory (nullptr);
128
129 if (mModule)
130 {
131 if (auto moduleExit = getFunctionPointer<ModuleExitFunc> ("ModuleExit"))
132 moduleExit ();
133
134 dlclose (mModule);
135 }
136 }
static RegisteredToolbarFactory factory

References factory.

Member Function Documentation

◆ getFunctionPointer()

template<typename T >
T VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule::getFunctionPointer ( const char *  name)
inline

Definition at line 120 of file module_linux.cpp.

121 {
122 return reinterpret_cast<T> (dlsym (mModule, name));
123 }
wxString name
Definition: TagsEditor.cpp:166

References name.

◆ getSOPath()

static Optional< Path > VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule::getSOPath ( const std::string &  inPath)
inlinestatic

Definition at line 138 of file module_linux.cpp.

139 {
140 Path modulePath {inPath};
141 if (!filesystem::is_directory (modulePath))
142 return {};
143
144 auto stem = modulePath.stem ();
145
146 modulePath /= "Contents";
147 if (!filesystem::is_directory (modulePath))
148 return {};
149
150 // use the Machine Hardware Name (from uname cmd-line) as prefix for "-linux"
151 auto machine = getCurrentMachineName ();
152 if (!machine)
153 return {};
154
155 modulePath /= *machine + "-linux";
156 if (!filesystem::is_directory (modulePath))
157 return {};
158
159 stem.replace_extension (".so");
160 modulePath /= stem;
161 return Optional<Path> (std::move (modulePath));
162 }
filesystem::path Path

References VST3::Hosting::anonymous_namespace{module_linux.cpp}::getCurrentMachineName().

Here is the call graph for this function:

◆ load()

bool VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule::load ( const std::string &  inPath,
std::string &  errorDescription 
)
inlineoverride

Definition at line 164 of file module_linux.cpp.

165 {
166 auto modulePath = getSOPath (inPath);
167 if (!modulePath)
168 {
169 errorDescription = inPath + " is not a module directory.";
170 return false;
171 }
172
173 mModule = dlopen (reinterpret_cast<const char*> (modulePath->generic_string ().data ()),
174 RTLD_LAZY);
175 if (!mModule)
176 {
177 errorDescription = "dlopen failed.\n";
178 errorDescription += dlerror ();
179 return false;
180 }
181 // ModuleEntry is mandatory
182 auto moduleEntry = getFunctionPointer<ModuleEntryFunc> ("ModuleEntry");
183 if (!moduleEntry)
184 {
185 errorDescription =
186 "The shared library does not export the required 'ModuleEntry' function";
187 return false;
188 }
189 // ModuleExit is mandatory
190 auto moduleExit = getFunctionPointer<ModuleExitFunc> ("ModuleExit");
191 if (!moduleExit)
192 {
193 errorDescription =
194 "The shared library does not export the required 'ModuleExit' function";
195 return false;
196 }
197 auto factoryProc = getFunctionPointer<GetFactoryProc> ("GetPluginFactory");
198 if (!factoryProc)
199 {
200 errorDescription =
201 "The shared library does not export the required 'GetPluginFactory' function";
202 return false;
203 }
204
205 if (!moduleEntry (mModule))
206 {
207 errorDescription = "Calling 'ModuleEntry' failed";
208 return false;
209 }
210 auto f = Steinberg::FUnknownPtr<Steinberg::IPluginFactory> (owned (factoryProc ()));
211 if (!f)
212 {
213 errorDescription = "Calling 'GetPluginFactory' returned nullptr";
214 return false;
215 }
216 factory = PluginFactory (f);
217 return true;
218 }
static Optional< Path > getSOPath(const std::string &inPath)

References factory.

Member Data Documentation

◆ mModule

void* VST3::Hosting::anonymous_namespace{module_linux.cpp}::LinuxModule::mModule {nullptr}

Definition at line 220 of file module_linux.cpp.


The documentation for this class was generated from the following file: