Browse Source

Drivers/internals loading code cleanup.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4682 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.9.5
sletz 14 years ago
parent
commit
107d210e1d
1 changed files with 9 additions and 78 deletions
  1. +9
    -78
      common/JackDriverLoader.cpp

+ 9
- 78
common/JackDriverLoader.cpp View File

@@ -34,42 +34,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


#ifdef WIN32 #ifdef WIN32


static char* locate_application_driver_dir()
{
char driver_dir_storage[512];

// For WIN32 ADDON_DIR is defined in JackConstants.h as relative path
if (3 < GetModuleFileName(NULL, driver_dir_storage, 512)) {
char *p = strrchr(driver_dir_storage, '\\');
if (p && (p != driver_dir_storage)) {
*p = 0;
} else {
GetCurrentDirectory(512, driver_dir_storage);
}
} else {
GetCurrentDirectory(512, driver_dir_storage);
}

strcat(driver_dir_storage, "/");
strcat(driver_dir_storage, ADDON_DIR);
return strdup(driver_dir_storage);
}

static char* locate_system_driver_dir()
{
char driver_dir_storage[512];

// For WIN32 ADDON_DIR is defined in JackConstants.h as relative path
if (3 < GetSystemDirectory(driver_dir_storage, 512)) {
strcat(driver_dir_storage, "/");
strcat(driver_dir_storage, ADDON_DIR);
return strdup(driver_dir_storage);
} else {
jack_error("Cannot get system directory : %d", GetLastError());
return NULL;
}
}

static char* locate_dll_driver_dir() static char* locate_dll_driver_dir()
{ {
#ifdef _WIN64 #ifdef _WIN64
@@ -84,51 +48,18 @@ static char* locate_dll_driver_dir()
char *p = strrchr(driver_dir_storage, '\\'); char *p = strrchr(driver_dir_storage, '\\');
if (p && (p != driver_dir_storage)) { if (p && (p != driver_dir_storage)) {
*p = 0; *p = 0;
} else {
GetCurrentDirectory(512, driver_dir_storage);
}
} else {
GetCurrentDirectory(512, driver_dir_storage);
}

strcat(driver_dir_storage, "/");
strcat(driver_dir_storage, ADDON_DIR);
return strdup(driver_dir_storage);
}

/*
static char* locate_driver_dir(HANDLE& file, WIN32_FIND_DATA& filedata)
{
char dll_filename[512];

// Search drivers/internals near the application
char* driver_dir = locate_application_driver_dir();
snprintf(dll_filename, sizeof(dll_filename), "%s/*.dll", driver_dir);
file = (HANDLE)FindFirstFile(dll_filename, &filedata);

if (file == INVALID_HANDLE_VALUE) {
jack_info("Drivers/internals not found near application");

// Otherwise search drivers/internals in the system
free(driver_dir);
driver_dir = locate_system_driver_dir();
snprintf(dll_filename, sizeof(dll_filename), "%s/*.dll", driver_dir);
file = (HANDLE)FindFirstFile(dll_filename, &filedata);

if (file == INVALID_HANDLE_VALUE) {
jack_info("Drivers/internals not found in system location");
free(driver_dir);
return NULL;
} else {
jack_info("Drivers/internals found in system location");
} }
jack_info("Drivers/internals found in : %s", driver_dir_storage);
strcat(driver_dir_storage, "/");
strcat(driver_dir_storage, ADDON_DIR);
FreeLibrary(libjack_handle);
return strdup(driver_dir_storage);
} else { } else {
jack_info("Drivers/internals found near application");
jack_error("Cannot get JACK dll directory : %d", GetLastError());
FreeLibrary(libjack_handle);
return NULL;
} }

return driver_dir;
} }
*/


static char* locate_driver_dir(HANDLE& file, WIN32_FIND_DATA& filedata) static char* locate_driver_dir(HANDLE& file, WIN32_FIND_DATA& filedata)
{ {
@@ -140,7 +71,7 @@ static char* locate_driver_dir(HANDLE& file, WIN32_FIND_DATA& filedata)


if (file == INVALID_HANDLE_VALUE) { if (file == INVALID_HANDLE_VALUE) {
jack_error("Drivers not found "); jack_error("Drivers not found ");
free(driver_dir)
free(driver_dir);
return NULL; return NULL;
} else { } else {
return driver_dir; return driver_dir;


Loading…
Cancel
Save