MCPcopy Create free account
hub / github.com/audacity/audacity / load

Function load

libraries/lib-vst3/module_win32.cpp:148–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 }
147
148 bool load (const std::string& inPath, std::string& errorDescription) override
149 {
150 auto wideStr = StringConvert::convert (inPath);
151 mModule = LoadLibraryW (reinterpret_cast<LPCWSTR> (wideStr.data ()));
152 if (!mModule)
153 {
154 filesystem::path p (inPath);
155 auto filename = p.filename ();
156 p /= "Contents";
157 p /= architectureString;
158 p /= filename;
159 wideStr = StringConvert::convert (p.string ());
160 mModule = LoadLibraryW (reinterpret_cast<LPCWSTR> (wideStr.data ()));
161 if (!mModule)
162 {
163 auto lastError = GetLastError ();
164 LPVOID lpMessageBuffer;
165 FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
166 nullptr, lastError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
167 (LPSTR)&lpMessageBuffer, 0, nullptr);
168 errorDescription = "LoadLibray failed: " + std::string ((char*)lpMessageBuffer);
169 LocalFree (lpMessageBuffer);
170
171 return false;
172 }
173 }
174 auto factoryProc = getFunctionPointer<GetFactoryProc> ("GetPluginFactory");
175 if (!factoryProc)
176 {
177 errorDescription = "The dll does not export the required 'GetPluginFactory' function";
178 return false;
179 }
180 // InitDll is optional
181 auto dllEntry = getFunctionPointer<InitModuleFunc> ("InitDll");
182 if (dllEntry && !dllEntry ())
183 {
184 errorDescription = "Calling 'InitDll' failed";
185 return false;
186 }
187 auto f = Steinberg::FUnknownPtr<Steinberg::IPluginFactory> (owned (factoryProc ()));
188 if (!f)
189 {
190 errorDescription = "Calling 'GetPluginFactory' returned nullptr";
191 return false;
192 }
193 factory = PluginFactory (f);
194 return true;
195 }
196
197 HINSTANCE mModule {nullptr};
198};

Callers 13

DITHER_LOOPFunction · 0.85
initMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
reloadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
onProjectChangedMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85

Calls 1

dataMethod · 0.45

Tested by

no test coverage detected