mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 13:57:57 -07:00
code clean up, for dll loading, note that this didn't add new errors
just made old one visable, so complains about DllDebugger and missing symbols should be refered to the one who added the symbol without making sure the plugin actually has it. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1564 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2a2a83b7c8
commit
eea2f0520b
@ -33,10 +33,11 @@ DynamicLibrary::DynamicLibrary()
|
||||
library = 0;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
std::string GetLastErrorAsString()
|
||||
{
|
||||
LPVOID lpMsgBuf = 0;
|
||||
#ifdef _WIN32
|
||||
LPVOID lpMsgBuf = 0;
|
||||
DWORD error = GetLastError();
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
@ -54,6 +55,13 @@ std::string GetLastErrorAsString()
|
||||
s = StringFromFormat("(unknown error %08x)", error);
|
||||
}
|
||||
return s;
|
||||
#else
|
||||
static std::string errstr;
|
||||
char *tmp = dlerror();
|
||||
if (tmp)
|
||||
errstr = tmp;
|
||||
|
||||
return errstr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -68,6 +76,7 @@ int DynamicLibrary::Load(const char* filename)
|
||||
if (!filename || strlen(filename) == 0)
|
||||
{
|
||||
LOG(MASTER_LOG, "Missing filename of dynamic library to load");
|
||||
PanicAlert("Missing filename of dynamic library to load");
|
||||
return 0;
|
||||
}
|
||||
LOG(MASTER_LOG, "Trying to load library %s", filename);
|
||||
@ -80,71 +89,72 @@ int DynamicLibrary::Load(const char* filename)
|
||||
|
||||
#ifdef _WIN32
|
||||
library = LoadLibrary(filename);
|
||||
if (!library) {
|
||||
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str());
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
library = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||
if (!library)
|
||||
{
|
||||
#ifdef LOGGING
|
||||
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, dlerror());
|
||||
#else
|
||||
printf("Error loading DLL %s: %s", filename, dlerror());
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!library) {
|
||||
LOG(MASTER_LOG, "Error loading DLL %s: %s", filename, GetLastErrorAsString().c_str());
|
||||
PanicAlert("Error loading DLL %s: %s\n", filename, GetLastErrorAsString().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
library_file = filename;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void DynamicLibrary::Unload()
|
||||
int DynamicLibrary::Unload()
|
||||
{
|
||||
if (!IsLoaded())
|
||||
{
|
||||
PanicAlert("Trying to unload non-loaded library");
|
||||
return;
|
||||
}
|
||||
int retval;
|
||||
if (!IsLoaded()) {
|
||||
LOG(MASTER_LOG, "Error unloading DLL %s: not loaded", library_file.c_str());
|
||||
PanicAlert("Error unloading DLL %s: not loaded", library_file.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
/* TEMPORARY SOLUTION: To prevent that Dolphin hangs when a game is stopped
|
||||
or when we try to close Dolphin. It's possible that it only occur when we render
|
||||
to the main window. And sometimes FreeLibrary works without any problem, so
|
||||
don't remove this just because it doesn't hang once. I could not find the
|
||||
actual cause of it. */
|
||||
if( ! (library_file.find("OGL.") != std::string::npos) && !PowerPC::CPU_POWERDOWN)
|
||||
FreeLibrary(library);
|
||||
if( ! (library_file.find("OGL.") != std::string::npos) && !PowerPC::CPU_POWERDOWN)
|
||||
retval = FreeLibrary(library);
|
||||
#else
|
||||
dlclose(library);
|
||||
retval = dlclose(library);
|
||||
#endif
|
||||
library = 0;
|
||||
if (!retval) {
|
||||
LOG(MASTER_LOG, "Error unloading DLL %s: %s", library_file.c_str(),
|
||||
GetLastErrorAsString().c_str());
|
||||
PanicAlert("Error unloading DLL %s: %s", library_file.c_str(),
|
||||
GetLastErrorAsString().c_str());
|
||||
}
|
||||
library = 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
void* DynamicLibrary::Get(const char* funcname) const
|
||||
{
|
||||
void* retval;
|
||||
#ifdef _WIN32
|
||||
if (!library)
|
||||
{
|
||||
PanicAlert("Can't find function %s - Library not loaded.");
|
||||
LOG(MASTER_LOG, "Can't find function %s - Library not loaded.");
|
||||
PanicAlert("Can't find function %s - Library not loaded.");
|
||||
}
|
||||
#ifdef _WIN32
|
||||
retval = GetProcAddress(library, funcname);
|
||||
//if (!retval)
|
||||
//{
|
||||
// PanicAlert("Did not find function %s in library %s.", funcname, library_file.c_str());
|
||||
//}
|
||||
#else
|
||||
retval = dlsym(library, funcname);
|
||||
|
||||
if (!retval)
|
||||
{
|
||||
printf("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), dlerror());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!retval) {
|
||||
LOG(MASTER_LOG, "Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
PanicAlert("Symbol %s missing in %s (error: %s)\n", funcname, library_file.c_str(), GetLastErrorAsString().c_str());
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class DynamicLibrary
|
||||
|
||||
DynamicLibrary();
|
||||
int Load(const char* filename);
|
||||
void Unload();
|
||||
int Unload();
|
||||
void* Get(const char* funcname) const;
|
||||
|
||||
bool IsLoaded() const {return(library != 0);}
|
||||
|
@ -32,7 +32,6 @@ namespace Common
|
||||
DynamicLibrary CPlugin::m_hInstLib;
|
||||
|
||||
void(__cdecl * CPlugin::m_GetDllInfo) (PLUGIN_INFO * _PluginInfo) = 0;
|
||||
//void(__cdecl * CPlugin::m_DllAbout) (HWND _hParent) = 0;
|
||||
void(__cdecl * CPlugin::m_DllConfig) (HWND _hParent) = 0;
|
||||
void(__cdecl * CPlugin::m_DllDebugger) (HWND _hParent, bool Show) = 0;
|
||||
|
||||
@ -40,7 +39,6 @@ void
|
||||
CPlugin::Release(void)
|
||||
{
|
||||
m_GetDllInfo = 0;
|
||||
//m_DllAbout = 0;
|
||||
m_DllConfig = 0;
|
||||
m_DllDebugger = 0;
|
||||
|
||||
@ -82,14 +80,6 @@ void CPlugin::Config(HWND _hwnd)
|
||||
}
|
||||
}
|
||||
|
||||
//void CPlugin::About(HWND _hwnd)
|
||||
//{
|
||||
// if (m_DllAbout != 0)
|
||||
// {
|
||||
// m_DllAbout(_hwnd);
|
||||
// }
|
||||
//}
|
||||
|
||||
void CPlugin::Debug(HWND _hwnd, bool Show)
|
||||
{
|
||||
if (m_DllDebugger != 0)
|
||||
|
@ -124,19 +124,15 @@ bool Init(const SCoreStartupParameter _CoreParameter)
|
||||
|
||||
// load plugins
|
||||
if (!PluginDSP::LoadPlugin(g_CoreStartupParameter.m_strDSPPlugin.c_str())) {
|
||||
PanicAlert("Failed to load DSP plugin %s", g_CoreStartupParameter.m_strDSPPlugin.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!PluginPAD::LoadPlugin(g_CoreStartupParameter.m_strPadPlugin.c_str())) {
|
||||
PanicAlert("Failed to load PAD plugin %s", g_CoreStartupParameter.m_strPadPlugin.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!PluginVideo::LoadPlugin(g_CoreStartupParameter.m_strVideoPlugin.c_str())) {
|
||||
PanicAlert("Failed to load video plugin %s", g_CoreStartupParameter.m_strVideoPlugin.c_str());
|
||||
return false;
|
||||
}
|
||||
if (!PluginWiimote::LoadPlugin(g_CoreStartupParameter.m_strWiimotePlugin.c_str())) {
|
||||
PanicAlert("Failed to load Wiimote plugin %s", g_CoreStartupParameter.m_strWiimotePlugin.c_str());
|
||||
if (_CoreParameter.bWii && !PluginWiimote::LoadPlugin(g_CoreStartupParameter.m_strWiimotePlugin.c_str())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -154,8 +150,6 @@ bool Init(const SCoreStartupParameter _CoreParameter)
|
||||
|
||||
//PluginVideo::DllDebugger(NULL);
|
||||
|
||||
//RegisterPanicAlertHandler(PanicAlertToVideo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,8 @@ if sys.platform == 'darwin':
|
||||
linkFlags.append('-L/opt/local/lib')
|
||||
conf.CheckPKG('OpenGL')
|
||||
if not conf.CheckPKG('Cg'):
|
||||
print name + " must have Cg from nvidia to be build"
|
||||
print name + " must have Cg framework from nvidia to be build"
|
||||
Return()
|
||||
|
||||
else:
|
||||
if not (conf.CheckPKG('GL') and conf.CheckPKG('GLU')):
|
||||
|
Loading…
Reference in New Issue
Block a user