Commit 30fb35f2 authored by sletz's avatar sletz
Browse files

Cleanup JackInternalClient code.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3472 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 849e366f
......@@ -24,7 +24,11 @@ Torben Hohn
Jackdmp changes log
---------------------------
2009-03-26 Stephane Letz <letz@grame.fr>
2009-03-29 Stephane Letz <letz@grame.fr>
* Cleanup JackInternalClient code.
2009-03-27 Stephane Letz <letz@grame.fr>
* Add a buffer size callback for netmaster that just remove the client (it will be recreated with the new parameters).
......
......@@ -262,10 +262,10 @@ namespace Jack
int JackAudioAdapterInterface::PullAndPush(float** inputBuffer, float** outputBuffer, unsigned int frames)
{
fPullAndPushTime = GetMicroSeconds();
if (!fRunning)
return 0;
if (!fRunning)
return 0;
int res = 0;
int res = 0;
// Push/pull from ringbuffer
for (int i = 0; i < fCaptureChannels; i++) {
......
......@@ -432,8 +432,7 @@ jack_get_descriptor (JSList * drivers, const char * sofile, const char * symbol)
return NULL;
}
so_get_descriptor = (JackDriverDescFunction)
GetProc(dlhandle, symbol);
so_get_descriptor = (JackDriverDescFunction)GetDriverProc(dlhandle, symbol);
#ifdef WIN32
if ((so_get_descriptor == NULL) && (dlerr = GetLastError()) != 0) {
......@@ -513,7 +512,7 @@ static bool check_symbol(const char* sofile, const char* symbol)
jack_error ("could not open component .so '%s': %s", filename, dlerror());
#endif
} else {
res = (GetProc(dlhandle, symbol)) ? true : false;
res = (GetDriverProc(dlhandle, symbol)) ? true : false;
UnloadDriverModule(dlhandle);
}
......@@ -791,7 +790,7 @@ Jack::JackDriverClientInterface* JackDriverInfo::Open(jack_driver_desc_t* driver
return NULL;
}
fInitialize = (driverInitialize)GetProc(fHandle, "driver_initialize");
fInitialize = (driverInitialize)GetDriverProc(fHandle, "driver_initialize");
#ifdef WIN32
if ((fInitialize == NULL) && (errstr = GetLastError ()) != 0) {
......
......@@ -34,58 +34,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
namespace Jack
{
#ifdef WIN32
static void BuildClientPath(char* path_to_so, int path_len, const char* so_name)
{
snprintf(path_to_so, path_len, ADDON_DIR "/%s.dll", so_name);
}
static void PrintLoadError(const char* so_name)
{
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)so_name) + 40) * sizeof(TCHAR));
_snprintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("error loading %s err = %s"), so_name, lpMsgBuf);
jack_error((LPCTSTR)lpDisplayBuf);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
#else
static void BuildClientPath(char* path_to_so, int path_len, const char* so_name)
{
const char* internal_dir;
if ((internal_dir = getenv("JACK_INTERNAL_DIR")) == 0) {
if ((internal_dir = getenv("JACK_DRIVER_DIR")) == 0) {
internal_dir = ADDON_DIR;
}
}
snprintf(path_to_so, path_len, "%s/%s.so", internal_dir, so_name);
}
#endif
JackGraphManager* JackInternalClient::fGraphManager = NULL;
JackEngineControl* JackInternalClient::fEngineControl = NULL;
......
......@@ -60,25 +60,6 @@ class JackInternalClient : public JackClient
\brief Loadable internal clients in the server.
*/
#ifdef WIN32
#include <windows.h>
#define HANDLE HINSTANCE
#define LoadJackModule(name) LoadLibrary((name));
#define UnloadJackModule(handle) FreeLibrary((handle));
#define GetJackProc(handle, name) GetProcAddress((handle), (name));
#else
#include <dlfcn.h>
#define HANDLE void*
#define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL);
#define UnloadJackModule(handle) dlclose((handle));
#define GetJackProc(handle, name) dlsym((handle), (name));
#define PrintLoadError(so_name) jack_log("error loading %s err = %s", so_name, dlerror());
#endif
typedef int (*InitializeCallback)(jack_client_t*, const char*);
typedef int (*InternalInitializeCallback)(jack_client_t*, const JSList* params);
typedef void (*FinishCallback)(void *);
......@@ -89,7 +70,7 @@ class JackLoadableInternalClient : public JackInternalClient
protected:
HANDLE fHandle;
JACK_HANDLE fHandle;
FinishCallback fFinish;
JackDriverDescFunction fDescriptor;
......
......@@ -212,6 +212,63 @@ namespace Jack {
}
new_name[i] = '\0';
}
#ifdef WIN32
void BuildClientPath(char* path_to_so, int path_len, const char* so_name)
{
snprintf(path_to_so, path_len, ADDON_DIR "/%s.dll", so_name);
}
void PrintLoadError(const char* so_name)
{
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
LPVOID lpDisplayBuf;
DWORD dw = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
// Display the error message and exit the process
lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT,
(lstrlen((LPCTSTR)lpMsgBuf) + lstrlen((LPCTSTR)so_name) + 40) * sizeof(TCHAR));
_snprintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR),
TEXT("error loading %s err = %s"), so_name, lpMsgBuf);
jack_error((LPCTSTR)lpDisplayBuf);
LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
}
#else
void PrintLoadError(const char* so_name)
{
jack_log("error loading %s err = %s", so_name, dlerror());
}
void BuildClientPath(char* path_to_so, int path_len, const char* so_name)
{
const char* internal_dir;
if ((internal_dir = getenv("JACK_INTERNAL_DIR")) == 0) {
if ((internal_dir = getenv("JACK_DRIVER_DIR")) == 0) {
internal_dir = ADDON_DIR;
}
}
snprintf(path_to_so, path_len, "%s/%s.so", internal_dir, so_name);
}
#endif
} // end of namespace
......@@ -201,6 +201,10 @@ namespace Jack
return 0;
}
};
void BuildClientPath(char* path_to_so, int path_len, const char* so_name);
void PrintLoadError(const char* so_name);
}
#endif
......@@ -28,7 +28,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define DRIVER_HANDLE void*
#define LoadDriverModule(name) dlopen((name), RTLD_NOW | RTLD_GLOBAL)
#define UnloadDriverModule(handle) dlclose((handle))
#define GetProc(handle, name) dlsym((handle), (name))
#define GetDriverProc(handle, name) dlsym((handle), (name))
#define JACK_HANDLE void*
#define LoadJackModule(name) dlopen((name), RTLD_NOW | RTLD_LOCAL);
#define UnloadJackModule(handle) dlclose((handle));
#define GetJackProc(handle, name) dlsym((handle), (name));
#define JACK_DEBUG (getenv("JACK_CLIENT_DEBUG") && strcmp(getenv("JACK_CLIENT_DEBUG"), "on") == 0)
......
......@@ -25,10 +25,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define DRIVER_HANDLE HINSTANCE
#define LoadDriverModule(name) LoadLibrary((name))
#define UnloadDriverModule(handle) (FreeLibrary(((HMODULE)handle)))
#define GetProc(handle, name) GetProcAddress(((HMODULE)handle),(name))
#define GetDriverProc(handle, name) GetProcAddress(((HMODULE)handle), (name))
#define ENOBUFS 55
#define HANDLE HINSTANCE
#define LoadJackModule(name) LoadLibrary((name));
#define UnloadJackModule(handle) FreeLibrary((handle));
#define GetJackProc(handle, name) GetProcAddress((handle), (name));
#define ENOBUFS 55
#define JACK_DEBUG false
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment