00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef WIN32
00022 #pragma warning (disable : 4786)
00023 #endif
00024
00025 #include "JackGraphManager.h"
00026 #include "JackInternalClient.h"
00027 #include "JackServer.h"
00028 #include "JackDebugClient.h"
00029 #include "JackServerGlobals.h"
00030 #include "JackError.h"
00031 #include "JackServerLaunch.h"
00032 #include "JackTools.h"
00033
00034 #ifdef WIN32
00035 #define EXPORT __declspec(dllexport)
00036 #else
00037 #define EXPORT
00038 #endif
00039
00040 #ifdef __cplusplus
00041 extern "C"
00042 {
00043 #endif
00044
00045 EXPORT jack_client_t * jack_client_open (const char *client_name,
00046 jack_options_t options,
00047 jack_status_t *status, ...);
00048 EXPORT int jack_client_close (jack_client_t *client);
00049
00050 #ifdef __cplusplus
00051 }
00052 #endif
00053
00054 using namespace Jack;
00055
00056 EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
00057 {
00058 va_list ap;
00059 jack_varargs_t va;
00060 jack_status_t my_status;
00061 JackClient* client;
00062 char client_name[JACK_CLIENT_NAME_SIZE];
00063
00064 JackTools::RewriteName(ext_client_name, client_name);
00065
00066 if (status == NULL)
00067 status = &my_status;
00068 *status = (jack_status_t)0;
00069
00070
00071 if ((options & ~JackOpenOptions)) {
00072 int my_status1 = *status | (JackFailure | JackInvalidOption);
00073 *status = (jack_status_t)my_status1;
00074 return NULL;
00075 }
00076
00077
00078 va_start(ap, status);
00079 jack_varargs_parse(options, ap, &va);
00080 va_end(ap);
00081
00082 JackLog("jack_client_open %s\n", client_name);
00083 if (client_name == NULL) {
00084 jack_error("jack_client_new called with a NULL client_name");
00085 return NULL;
00086 }
00087
00088 if (!JackServerGlobals::Init()) {
00089 int my_status1 = (JackFailure | JackServerError);
00090 *status = (jack_status_t)my_status1;
00091 return NULL;
00092 }
00093
00094 #ifndef WIN32
00095 char* jack_debug = getenv("JACK_CLIENT_DEBUG");
00096 if (jack_debug && strcmp(jack_debug, "on") == 0)
00097 client = new JackDebugClient(new JackInternalClient(JackServer::fInstance, GetSynchroTable()));
00098 else
00099 client = new JackInternalClient(JackServer::fInstance, GetSynchroTable());
00100 #else
00101 client = new JackInternalClient(JackServer::fInstance, GetSynchroTable());
00102 #endif
00103
00104 int res = client->Open(va.server_name, client_name, options, status);
00105 if (res < 0) {
00106 delete client;
00107 JackServerGlobals::Destroy();
00108 int my_status1 = (JackFailure | JackServerError);
00109 *status = (jack_status_t)my_status1;
00110 return NULL;
00111 } else {
00112 return (jack_client_t*)client;
00113 }
00114 }
00115
00116 EXPORT int jack_client_close(jack_client_t* ext_client)
00117 {
00118 JackLog("jack_client_close\n");
00119 JackClient* client = (JackClient*)ext_client;
00120 if (client == NULL) {
00121 jack_error("jack_client_close called with a NULL client");
00122 return -1;
00123 } else {
00124 int res = client->Close();
00125 delete client;
00126 JackLog("jack_client_close OK\n");
00127 JackServerGlobals::Destroy();
00128 return res;
00129 }
00130 }
00131