Browse Source

New JackDriverInfo class to cleanup driver loading code.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2924 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.90
sletz 15 years ago
parent
commit
2097c37f35
6 changed files with 48 additions and 49 deletions
  1. +4
    -0
      ChangeLog
  2. +16
    -25
      common/JackDriverLoader.cpp
  3. +21
    -7
      common/JackDriverLoader.h
  4. +4
    -12
      common/JackServer.cpp
  5. +2
    -4
      common/JackServer.h
  6. +1
    -1
      macosx/JackMachThread.cpp

+ 4
- 0
ChangeLog View File

@@ -22,6 +22,10 @@ Florian Faber
Jackdmp changes log
---------------------------

2008-08-17 Stephane Letz <letz@grame.fr>
* New JackDriverInfo class to cleanup driver loading code.

2008-08-08 Stephane Letz <letz@grame.fr>
* Better symbols export for server and client side libraries.


+ 16
- 25
common/JackDriverLoader.cpp View File

@@ -769,20 +769,20 @@ jack_internals_load (JSList * internals) {

#endif

jack_driver_info_t *
jack_load_driver (jack_driver_desc_t * driver_desc) {
Jack::JackDriverClientInterface* JackDriverInfo::Open(jack_driver_desc_t* driver_desc,
Jack::JackLockedEngine* engine,
Jack::JackSynchro* synchro,
const JSList* params)
{
#ifdef WIN32
int errstr;
#else
const char * errstr;
#endif

jack_driver_info_t *info;

info = (jack_driver_info_t *) calloc (1, sizeof (*info));
info->handle = LoadDriverModule (driver_desc->file);

if (info->handle == NULL) {
fHandle = LoadDriverModule (driver_desc->file);
if (fHandle == NULL) {
#ifdef WIN32
if ((errstr = GetLastError ()) != 0) {
jack_error ("can't load \"%s\": %ld", driver_desc->file,
@@ -794,31 +794,22 @@ jack_load_driver (jack_driver_desc_t * driver_desc) {
#endif

} else {
jack_error ("bizarre error loading driver shared "
"object %s", driver_desc->file);
jack_error ("bizarre error loading driver shared object %s", driver_desc->file);
}
goto fail;
return NULL;
}

info->initialize = (initialize)GetProc(info->handle, "driver_initialize");
fInitialize = (driverInitialize)GetProc(fHandle, "driver_initialize");

#ifdef WIN32
if ((info->initialize == NULL) && (errstr = GetLastError ()) != 0) {
if ((fInitialize == NULL) && (errstr = GetLastError ()) != 0) {
#else
if ((info->initialize == NULL) && (errstr = dlerror ()) != 0) {
if ((fInitialize == NULL) && (errstr = dlerror ()) != 0) {
#endif
jack_error ("no initialize function in shared object %s\n",
driver_desc->file);
goto fail;
jack_error("no initialize function in shared object %s\n", driver_desc->file);
return NULL;
}

return info;

fail:
if (info->handle) {
UnloadDriverModule(info->handle);
}
free (info);
return NULL;
return fInitialize(engine, synchro, params);
}


+ 21
- 7
common/JackDriverLoader.h View File

@@ -33,21 +33,35 @@ namespace Jack
};

typedef jack_driver_desc_t * (*JackDriverDescFunction) ();
typedef Jack::JackDriverClientInterface* (*initialize) (Jack::JackLockedEngine*, Jack::JackSynchro*, const JSList*);
typedef Jack::JackDriverClientInterface* (*driverInitialize) (Jack::JackLockedEngine*, Jack::JackSynchro*, const JSList*);

typedef struct _jack_driver_info
class JackDriverInfo
{
Jack::JackDriverClientInterface* (*initialize)(Jack::JackLockedEngine*, Jack::JackSynchro*, const JSList*);
DRIVER_HANDLE handle;
}
jack_driver_info_t;

private:
driverInitialize fInitialize;
DRIVER_HANDLE fHandle;
public:
JackDriverInfo():fInitialize(NULL),fHandle(NULL)
{}
~JackDriverInfo()
{
if (fHandle)
UnloadDriverModule(fHandle);
}
Jack::JackDriverClientInterface* Open(jack_driver_desc_t* driver_desc, Jack::JackLockedEngine*, Jack::JackSynchro*, const JSList*);
};

jack_driver_desc_t * jack_find_driver_descriptor (JSList * drivers, const char * name);

JSList * jack_drivers_load (JSList * drivers);
JSList * jack_internals_load (JSList * internals);

jack_driver_info_t * jack_load_driver (jack_driver_desc_t * driver_desc);
SERVER_EXPORT int jackctl_parse_driver_params (jackctl_driver * driver_ptr, int argc, char* argv[]);
SERVER_EXPORT void jack_free_driver_params(JSList * param_ptr);



+ 4
- 12
common/JackServer.cpp View File

@@ -23,7 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#endif

#include "JackSystemDeps.h"

#include "JackServer.h"
#include "JackTime.h"
#include "JackFreewheelDriver.h"
@@ -58,10 +57,10 @@ JackServer::JackServer(bool sync, bool temporary, long timeout, bool rt, long pr
fEngine = new JackLockedEngine(fGraphManager, GetSynchroTable(), fEngineControl);
fFreewheelDriver = new JackThreadedDriver(new JackFreewheelDriver(fEngine, GetSynchroTable()));
fLoopbackDriver = new JackLoopbackDriver(fEngine, GetSynchroTable());
fDriverInfo = new JackDriverInfo();
fAudioDriver = NULL;
fFreewheel = false;
fLoopback = loopback;
fDriverInfo = NULL;
fAudioDriver = NULL;
fInstance = this; // Unique instance
jack_verbose = verbose;
}
@@ -74,10 +73,7 @@ JackServer::~JackServer()
delete fLoopbackDriver;
delete fEngine;
delete fEngineControl;
if (fDriverInfo) {
UnloadDriverModule(fDriverInfo->handle);
free(fDriverInfo);
}
delete fDriverInfo;
}

int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
@@ -95,11 +91,7 @@ int JackServer::Open(jack_driver_desc_t* driver_desc, JSList* driver_params)
goto fail_close2;
}

if ((fDriverInfo = jack_load_driver(driver_desc)) == NULL) {
goto fail_close3;
}

if ((fAudioDriver = fDriverInfo->initialize(fEngine, GetSynchroTable(), driver_params)) == NULL) {
if ((fAudioDriver = fDriverInfo->Open(driver_desc, fEngine, GetSynchroTable(), driver_params)) == NULL) {
jack_error("Cannot initialize driver");
goto fail_close3;
}


+ 2
- 4
common/JackServer.h View File

@@ -25,11 +25,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "driver_interface.h"
#include "JackDriverLoader.h"
#include "JackConnectionManager.h"
#include "jslist.h"

#include "JackGlobals.h"
#include "JackPlatformPlug.h"
#include "jslist.h"

namespace Jack
{
@@ -49,7 +47,7 @@ class SERVER_EXPORT JackServer

private:

jack_driver_info_t* fDriverInfo;
JackDriverInfo* fDriverInfo;
JackDriverClientInterface* fAudioDriver;
JackDriverClientInterface* fFreewheelDriver;
JackDriverClientInterface* fLoopbackDriver;


+ 1
- 1
macosx/JackMachThread.cpp View File

@@ -161,9 +161,9 @@ int JackMachThread::AcquireRealTime()
{
jack_log("JackMachThread::AcquireRealTime fPeriod = %ld fComputation = %ld fConstraint = %ld",
long(fPeriod / 1000), long(fComputation / 1000), long(fConstraint / 1000));

return (fThread) ? AcquireRealTimeImp(fThread, fPeriod, fComputation, fConstraint) : -1;
}

int JackMachThread::AcquireRealTime(int priority)
{
fPriority = priority;


Loading…
Cancel
Save