2
Copyright (C) 2001-2003 Paul Davis
3
Copyright (C) 2004-2008 Grame
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU Lesser General Public License as published by
7
the Free Software Foundation; either version 2.1 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU Lesser General Public License for more details.
15
You should have received a copy of the GNU Lesser General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
#include "JackDebugClient.h"
22
#include "JackLibClient.h"
23
#include "JackChannel.h"
24
#include "JackLibGlobals.h"
25
#include "JackGlobals.h"
26
#include "JackCompilerDeps.h"
27
#include "JackTools.h"
28
#include "JackSystemDeps.h"
29
#include "JackServerLaunch.h"
39
EXPORT jack_client_t * jack_client_open_aux (const char *client_name,
40
jack_options_t options,
41
jack_status_t *status, va_list ap);
42
EXPORT jack_client_t * jack_client_open (const char *client_name,
43
jack_options_t options,
44
jack_status_t *status, ...);
45
EXPORT int jack_client_close (jack_client_t *client);
46
EXPORT int jack_get_client_pid (const char *name);
52
JackLibGlobals* JackLibGlobals::fGlobals = NULL;
53
int JackLibGlobals::fClientCount = 0;
55
EXPORT jack_client_t* jack_client_open_aux(const char* client_name, jack_options_t options, jack_status_t* status, va_list ap)
57
jack_varargs_t va; /* variable arguments */
58
jack_status_t my_status;
61
if (client_name == NULL) {
62
jack_error("jack_client_open called with a NULL client_name");
66
jack_log("jack_client_open %s", client_name);
68
if (status == NULL) /* no status from caller? */
69
status = &my_status; /* use local status word */
70
*status = (jack_status_t)0;
72
/* validate parameters */
73
if ((options & ~JackOpenOptions)) {
74
int my_status1 = *status | (JackFailure | JackInvalidOption);
75
*status = (jack_status_t)my_status1;
79
/* parse variable arguments */
81
jack_varargs_parse(options, ap, &va);
83
jack_varargs_init(&va);
86
JackLibGlobals::Init(); // jack library initialisation
88
if (try_start_server(&va, options, status)) {
89
jack_error("jack server is not running or cannot be started");
90
JackLibGlobals::Destroy(); // jack library destruction
95
client = new JackDebugClient(new JackLibClient(GetSynchroTable())); // Debug mode
97
client = new JackLibClient(GetSynchroTable());
100
int res = client->Open(va.server_name, client_name, options, status);
103
JackLibGlobals::Destroy(); // jack library destruction
104
int my_status1 = (JackFailure | JackServerError);
105
*status = (jack_status_t)my_status1;
108
return (jack_client_t*)client;
112
EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
115
#ifdef __CLIENTDEBUG__
116
JackGlobals::CheckContext("jack_client_open");
118
assert(JackGlobals::fOpenMutex);
119
JackGlobals::fOpenMutex->Lock();
121
va_start(ap, status);
122
jack_client_t* res = jack_client_open_aux(ext_client_name, options, status, ap);
124
JackGlobals::fOpenMutex->Unlock();
126
} catch(std::bad_alloc& e) {
127
jack_error("Memory allocation error...");
130
jack_error("Unknown error...");
135
EXPORT int jack_client_close(jack_client_t* ext_client)
137
#ifdef __CLIENTDEBUG__
138
JackGlobals::CheckContext("jack_client_close");
140
assert(JackGlobals::fOpenMutex);
141
JackGlobals::fOpenMutex->Lock();
143
jack_log("jack_client_close");
144
JackClient* client = (JackClient*)ext_client;
145
if (client == NULL) {
146
jack_error("jack_client_close called with a NULL client");
148
res = client->Close();
150
JackLibGlobals::Destroy(); // jack library destruction
151
jack_log("jack_client_close res = %d", res);
153
JackGlobals::fOpenMutex->Unlock();
157
EXPORT int jack_get_client_pid(const char *name)
159
jack_error("jack_get_client_pid : not implemented on library side");