2 Copyright (C) 2001-2003 Paul Davis
3 Copyright (C) 2004-2006 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #pragma warning (disable : 4786)
25 #include "JackInternalClient.h"
26 #include "JackGraphManager.h"
27 #include "JackServer.h"
28 #include "JackDebugClient.h"
29 #include "JackServerGlobals.h"
30 #include "JackError.h"
36 - implement the "jack_client_new", "jack_client_open", "jack_client_close" API so that we can provide a libjackdmp shared library
37 to be used by clients for direct access.
39 - automatic launch of the jack server with the first client open, automatic close when the last client exit. Use of a jackd.rsc configuration file.
44 #define EXPORT __declspec(dllexport)
54 EXPORT jack_client_t
* my_jack_internal_client_new(const char* client_name
);
55 EXPORT
void my_jack_internal_client_close(jack_client_t
* ext_client
);
57 EXPORT jack_client_t
* jack_client_open (const char *client_name
,
58 jack_options_t options
,
59 jack_status_t
*status
, ...);
60 EXPORT jack_client_t
* jack_client_new (const char *client_name
);
61 EXPORT
int jack_client_close (jack_client_t
*client
);
69 EXPORT jack_client_t
* my_jack_internal_client_new(const char* client_name
)
71 JackLog("jack_internal_client_new %s", client_name
);
72 if (client_name
== NULL
) {
73 jack_error("jack_internal_client_new called with a NULL client_name");
76 #ifdef __CLIENTDEBUG__
77 JackClient
* client
= new JackDebugClient(new JackInternalClient(JackServer::fInstance
, GetSynchroTable())); // Debug mode
79 JackClient
* client
= new JackInternalClient(JackServer::fInstance
, GetSynchroTable()); // To improve...
82 int res
= client
->Open(client_name
);
87 return (jack_client_t
*)client
;
91 EXPORT
void my_jack_internal_client_close(jack_client_t
* ext_client
)
93 JackLog("jack_internal_client_close");
94 JackClient
* client
= (JackClient
*)ext_client
;
96 jack_error("jack_internal_client_close called with a NULL client");
100 JackLog("jack_internal_client_close OK");
104 EXPORT jack_client_t
* jack_client_new(const char* client_name
)
106 int options
= JackUseExactName
;
107 if (getenv("JACK_START_SERVER") == NULL
)
108 options
|= JackNoStartServer
;
110 return jack_client_open(client_name
, (jack_options_t
)options
, NULL
);
113 // TO BE IMPLEMENTED PROPERLY
114 EXPORT jack_client_t
* jack_client_open(const char* client_name
, jack_options_t options
, jack_status_t
* status
, ...)
116 va_list ap
; /* variable argument pointer */
117 jack_varargs_t va
; /* variable arguments */
118 jack_status_t my_status
;
120 if (status
== NULL
) /* no status from caller? */
121 status
= &my_status
; /* use local status word */
122 *status
= (jack_status_t
)0;
124 /* validate parameters */
125 if ((options
& ~JackOpenOptions
)) {
126 int my_status1
= *status
| (JackFailure
| JackInvalidOption
);
127 *status
= (jack_status_t
)my_status1
;
131 /* parse variable arguments */
132 va_start(ap
, status
);
133 jack_varargs_parse(options
, ap
, &va
);
136 JackLog("jack_client_open %s\n", client_name
);
137 if (client_name
== NULL
) {
138 jack_error("jack_client_new called with a NULL client_name");
142 JackServerGlobals::Init(); // jack server initialisation
144 #ifdef __CLIENTDEBUG__
145 JackClient
* client
= new JackDebugClient(new JackInternalClient(JackServer::fInstance
, GetSynchroTable())); // Debug mode
147 JackClient
* client
= new JackInternalClient(JackServer::fInstance
, GetSynchroTable()); // To improve...
150 int res
= client
->Open(client_name
);
153 JackServerGlobals::Destroy(); // jack server destruction
156 *status
= (jack_status_t
)0;
157 return (jack_client_t
*)client
;
162 EXPORT
int jack_client_close(jack_client_t
* ext_client
)
164 JackLog("jack_client_close\n");
165 JackClient
* client
= (JackClient
*)ext_client
;
166 if (client
== NULL
) {
167 jack_error("jack_client_close called with a NULL client");
170 int res
= client
->Close();
172 JackLog("jack_client_close OK\n");
173 JackServerGlobals::Destroy(); // jack library destruction