JackAPI.cpp 61.9 KB
Newer Older
sletz's avatar
sletz committed
1
2
/*
Copyright (C) 2001-2003 Paul Davis
sletz's avatar
sletz committed
3
Copyright (C) 2004-2008 Grame
sletz's avatar
sletz committed
4
5

This program is free software; you can redistribute it and/or modify
sletz's avatar
sletz committed
6
7
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
sletz's avatar
sletz committed
8
9
10
11
12
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
sletz's avatar
sletz committed
13
GNU Lesser General Public License for more details.
sletz's avatar
sletz committed
14

sletz's avatar
sletz committed
15
You should have received a copy of the GNU Lesser General Public License
sletz's avatar
sletz committed
16
along with this program; if not, write to the Free Software
sletz's avatar
sletz committed
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
sletz's avatar
sletz committed
18
19
20
21
22
23
24
25
26
27

*/

#include "JackClient.h"
#include "JackError.h"
#include "JackGraphManager.h"
#include "JackEngineControl.h"
#include "JackClientControl.h"
#include "JackGlobals.h"
#include "JackTime.h"
28
#include "JackCompilerDeps.h"
sletz's avatar
sletz committed
29
#include "JackPortType.h"
sletz's avatar
sletz committed
30
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
31
32
#include <math.h>

33
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
34
#include "JackLibGlobals.h"
35
36
#endif

sletz's avatar
sletz committed
37
38
39
40
41
42
43
using namespace Jack;

#ifdef __cplusplus
extern "C"
{
#endif

44
45
46
    typedef void (*print_function)(const char *);
    typedef void *(*thread_routine)(void*);

sletz's avatar
sletz committed
47
48
49
50
51
52
53
54
55
56
57
58
    EXPORT
    void
    jack_get_version(
        int *major_ptr,
        int *minor_ptr,
        int *micro_ptr,
        int *proto_ptr);

    EXPORT
    const char *
    jack_get_version_string();

sletz's avatar
sletz committed
59
    jack_client_t * jack_client_new_aux (const char *client_name,
60
            jack_options_t options,
sletz's avatar
sletz committed
61
            jack_status_t *status);
62
    EXPORT jack_client_t * jack_client_open (const char *client_name,
sletz's avatar
Cleanup    
sletz committed
63
64
65
            jack_options_t options,
            jack_status_t *status, ...);
    EXPORT jack_client_t * jack_client_new (const char *client_name);
sletz's avatar
sletz committed
66
    EXPORT int jack_client_name_size (void);
sletz's avatar
sletz committed
67
68
69
70
71
    EXPORT char* jack_get_client_name (jack_client_t *client);
    EXPORT int jack_internal_client_new (const char *client_name,
                                         const char *load_name,
                                         const char *load_init);
    EXPORT void jack_internal_client_close (const char *client_name);
sletz's avatar
sletz committed
72
    EXPORT int jack_is_realtime (jack_client_t *client);
sletz's avatar
sletz committed
73
    EXPORT void jack_on_shutdown (jack_client_t *client,
74
                                  JackShutdownCallback shutdown_callback, void *arg);
75
76
    EXPORT void jack_on_info_shutdown (jack_client_t *client,
                                  JackInfoShutdownCallback shutdown_callback, void *arg);
sletz's avatar
sletz committed
77
78
79
    EXPORT int jack_set_process_callback (jack_client_t *client,
                                          JackProcessCallback process_callback,
                                          void *arg);
80
    EXPORT jack_nframes_t jack_thread_wait(jack_client_t *client, int status);
sletz's avatar
sletz committed
81
82
83
84
85
86
87

    // new
    EXPORT jack_nframes_t jack_cycle_wait (jack_client_t*);
    EXPORT void jack_cycle_signal (jack_client_t*, int status);
    EXPORT int jack_set_process_thread(jack_client_t* client, JackThreadCallback fun, void *arg);

    EXPORT int jack_set_thread_init_callback (jack_client_t *client,
sletz's avatar
sletz committed
88
89
90
91
92
93
94
95
96
97
98
99
100
            JackThreadInitCallback thread_init_callback,
            void *arg);
    EXPORT int jack_set_freewheel_callback (jack_client_t *client,
                                            JackFreewheelCallback freewheel_callback,
                                            void *arg);
    EXPORT int jack_set_freewheel(jack_client_t* client, int onoff);
    EXPORT int jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes);
    EXPORT int jack_set_buffer_size_callback (jack_client_t *client,
            JackBufferSizeCallback bufsize_callback,
            void *arg);
    EXPORT int jack_set_sample_rate_callback (jack_client_t *client,
            JackSampleRateCallback srate_callback,
            void *arg);
sletz's avatar
sletz committed
101
102
103
    EXPORT int jack_set_client_registration_callback (jack_client_t *,
            JackClientRegistrationCallback
            registration_callback, void *arg);
sletz's avatar
sletz committed
104
105
106
    EXPORT int jack_set_port_registration_callback (jack_client_t *,
            JackPortRegistrationCallback
            registration_callback, void *arg);
sletz's avatar
sletz committed
107
108
109
    EXPORT int jack_set_port_connect_callback (jack_client_t *,
            JackPortConnectCallback
            connect_callback, void *arg);
110
111
112
    EXPORT int jack_set_port_rename_callback (jack_client_t *,
				    JackPortRenameCallback
				    rename_callback, void *arg);
sletz's avatar
sletz committed
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
    EXPORT int jack_set_graph_order_callback (jack_client_t *,
            JackGraphOrderCallback graph_callback,
            void *);
    EXPORT int jack_set_xrun_callback (jack_client_t *,
                                       JackXRunCallback xrun_callback, void *arg);
    EXPORT int jack_activate (jack_client_t *client);
    EXPORT int jack_deactivate (jack_client_t *client);
    EXPORT jack_port_t * jack_port_register (jack_client_t *client,
            const char *port_name,
            const char *port_type,
            unsigned long flags,
            unsigned long buffer_size);
    EXPORT int jack_port_unregister (jack_client_t *, jack_port_t *);
    EXPORT void * jack_port_get_buffer (jack_port_t *, jack_nframes_t);
    EXPORT const char * jack_port_name (const jack_port_t *port);
    EXPORT const char * jack_port_short_name (const jack_port_t *port);
    EXPORT int jack_port_flags (const jack_port_t *port);
    EXPORT const char * jack_port_type (const jack_port_t *port);
sletz's avatar
sletz committed
131
    EXPORT jack_port_type_id_t jack_port_type_id (const jack_port_t *port);
sletz's avatar
sletz committed
132
133
134
135
136
137
138
139
140
141
    EXPORT int jack_port_is_mine (const jack_client_t *, const jack_port_t *port);
    EXPORT int jack_port_connected (const jack_port_t *port);
    EXPORT int jack_port_connected_to (const jack_port_t *port,
                                       const char *port_name);
    EXPORT const char ** jack_port_get_connections (const jack_port_t *port);
    EXPORT const char ** jack_port_get_all_connections (const jack_client_t *client,
            const jack_port_t *port);
    EXPORT int jack_port_tie (jack_port_t *src, jack_port_t *dst);
    EXPORT int jack_port_untie (jack_port_t *port);
    EXPORT jack_nframes_t jack_port_get_latency (jack_port_t *port);
sletz's avatar
sletz committed
142
    EXPORT jack_nframes_t jack_port_get_total_latency (jack_client_t *,
sletz's avatar
sletz committed
143
144
            jack_port_t *port);
    EXPORT void jack_port_set_latency (jack_port_t *, jack_nframes_t);
sletz's avatar
sletz committed
145
    EXPORT int jack_recompute_total_latency (jack_client_t*, jack_port_t* port);
sletz's avatar
sletz committed
146
147
    EXPORT int jack_recompute_total_latencies (jack_client_t*);
    EXPORT int jack_port_set_name (jack_port_t *port, const char *port_name);
sletz's avatar
sletz committed
148
149
150
    EXPORT int jack_port_set_alias (jack_port_t *port, const char *alias);
    EXPORT int jack_port_unset_alias (jack_port_t *port, const char *alias);
    EXPORT int jack_port_get_aliases (const jack_port_t *port, char* const aliases[2]);
sletz's avatar
sletz committed
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
    EXPORT int jack_port_request_monitor (jack_port_t *port, int onoff);
    EXPORT int jack_port_request_monitor_by_name (jack_client_t *client,
            const char *port_name, int onoff);
    EXPORT int jack_port_ensure_monitor (jack_port_t *port, int onoff);
    EXPORT int jack_port_monitoring_input (jack_port_t *port);
    EXPORT int jack_connect (jack_client_t *,
                             const char *source_port,
                             const char *destination_port);
    EXPORT int jack_disconnect (jack_client_t *,
                                const char *source_port,
                                const char *destination_port);
    EXPORT int jack_port_disconnect (jack_client_t *, jack_port_t *);
    EXPORT int jack_port_name_size(void);
    EXPORT int jack_port_type_size(void);
    EXPORT jack_nframes_t jack_get_sample_rate (jack_client_t *);
    EXPORT jack_nframes_t jack_get_buffer_size (jack_client_t *);
    EXPORT const char ** jack_get_ports (jack_client_t *,
                                         const char *port_name_pattern,
                                         const char *type_name_pattern,
                                         unsigned long flags);
    EXPORT jack_port_t * jack_port_by_name (jack_client_t *, const char *port_name);
sletz's avatar
sletz committed
172
    EXPORT jack_port_t * jack_port_by_id (jack_client_t *client,
sletz's avatar
sletz committed
173
174
175
                                          jack_port_id_t port_id);
    EXPORT int jack_engine_takeover_timebase (jack_client_t *);
    EXPORT jack_nframes_t jack_frames_since_cycle_start (const jack_client_t *);
sletz's avatar
sletz committed
176
    EXPORT jack_time_t jack_get_time();
177
178
    EXPORT jack_nframes_t jack_time_to_frames(const jack_client_t *client, jack_time_t time);
    EXPORT jack_time_t jack_frames_to_time(const jack_client_t *client, jack_nframes_t frames);
sletz's avatar
sletz committed
179
180
181
182
    EXPORT jack_nframes_t jack_frame_time (const jack_client_t *);
    EXPORT jack_nframes_t jack_last_frame_time (const jack_client_t *client);
    EXPORT float jack_cpu_load (jack_client_t *client);
    EXPORT pthread_t jack_client_thread_id (jack_client_t *);
183
184
    EXPORT void jack_set_error_function (print_function);
    EXPORT void jack_set_info_function (print_function);
sletz's avatar
sletz committed
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213

    EXPORT float jack_get_max_delayed_usecs (jack_client_t *client);
    EXPORT float jack_get_xrun_delayed_usecs (jack_client_t *client);
    EXPORT void jack_reset_max_delayed_usecs (jack_client_t *client);

    EXPORT int jack_release_timebase (jack_client_t *client);
    EXPORT int jack_set_sync_callback (jack_client_t *client,
                                       JackSyncCallback sync_callback,
                                       void *arg);
    EXPORT int jack_set_sync_timeout (jack_client_t *client,
                                      jack_time_t timeout);
    EXPORT int jack_set_timebase_callback (jack_client_t *client,
                                           int conditional,
                                           JackTimebaseCallback timebase_callback,
                                           void *arg);
    EXPORT int jack_transport_locate (jack_client_t *client,
                                      jack_nframes_t frame);
    EXPORT jack_transport_state_t jack_transport_query (const jack_client_t *client,
            jack_position_t *pos);
    EXPORT jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client);
    EXPORT int jack_transport_reposition (jack_client_t *client,
                                          jack_position_t *pos);
    EXPORT void jack_transport_start (jack_client_t *client);
    EXPORT void jack_transport_stop (jack_client_t *client);
    EXPORT void jack_get_transport_info (jack_client_t *client,
                                         jack_transport_info_t *tinfo);
    EXPORT void jack_set_transport_info (jack_client_t *client,
                                         jack_transport_info_t *tinfo);

214
215
    EXPORT int jack_client_real_time_priority (jack_client_t*);
    EXPORT int jack_client_max_real_time_priority (jack_client_t*);
sletz's avatar
sletz committed
216
217
218
219
220
    EXPORT int jack_acquire_real_time_scheduling (pthread_t thread, int priority);
    EXPORT int jack_client_create_thread (jack_client_t* client,
                                          pthread_t *thread,
                                          int priority,
                                          int realtime, 	// boolean
221
                                          thread_routine routine,
sletz's avatar
sletz committed
222
223
                                          void *arg);
    EXPORT int jack_drop_real_time_scheduling (pthread_t thread);
sletz's avatar
sletz committed
224

225
226
    EXPORT int jack_client_stop_thread (jack_client_t* client, pthread_t thread);
    EXPORT int jack_client_kill_thread (jack_client_t* client, pthread_t thread);
sletz's avatar
sletz committed
227
#ifndef WIN32
228
    EXPORT void jack_set_thread_creator (jack_thread_creator_t jtc);
sletz's avatar
sletz committed
229
#endif
sletz's avatar
sletz committed
230
231
232
233
234
235
236
237
238
    EXPORT char * jack_get_internal_client_name (jack_client_t *client,
            jack_intclient_t intclient);
    EXPORT jack_intclient_t jack_internal_client_handle (jack_client_t *client,
            const char *client_name,
            jack_status_t *status);
    EXPORT jack_intclient_t jack_internal_client_load (jack_client_t *client,
            const char *client_name,
            jack_options_t options,
            jack_status_t *status, ...);
239
    EXPORT jack_intclient_t jack_internal_client_load_aux (jack_client_t *client,
240
241
242
243
            const char *client_name,
            jack_options_t options,
            jack_status_t *status, va_list ap);

sletz's avatar
sletz committed
244
245
    EXPORT jack_status_t jack_internal_client_unload (jack_client_t *client,
            jack_intclient_t intclient);
246
    EXPORT void jack_free(void* ptr);
247

sletz's avatar
sletz committed
248
249
250
251
252
253
#ifdef __cplusplus
}
#endif

static inline bool CheckPort(jack_port_id_t port_index)
{
sletz's avatar
sletz committed
254
    return (port_index > 0 && port_index < PORT_NUM_MAX);
sletz's avatar
sletz committed
255
256
}

257
258
259
260
261
static inline bool CheckBufferSize(jack_nframes_t buffer_size)
{
    return (buffer_size <= BUFFER_SIZE_MAX);
}

sletz's avatar
sletz committed
262
263
static inline void WaitGraphChange()
{
264
    /*
sletz's avatar
sletz committed
265
    TLS key that is set only in RT thread, so never waits for pending
266
267
    graph change in RT context (just read the current graph state).
    */
sletz's avatar
sletz committed
268

269
    if (jack_tls_get(JackGlobals::fRealTime) == NULL) {
270
271
272
273
274
275
276
277
        JackGraphManager* manager = GetGraphManager();
        JackEngineControl* control = GetEngineControl();
        assert(manager);
        assert(control);
        if (manager->IsPendingChange()) {
            jack_log("WaitGraphChange...");
            JackSleep(int(control->fPeriodUsecs * 1.1f));
        }
sletz's avatar
sletz committed
278
279
280
    }
}

281
EXPORT void jack_set_error_function (print_function func)
sletz's avatar
sletz committed
282
{
283
    jack_error_callback = (func == NULL) ? &default_jack_error_callback : func;
sletz's avatar
sletz committed
284
285
}

286
EXPORT void jack_set_info_function (print_function func)
287
{
288
    jack_info_callback = (func == NULL) ? &default_jack_info_callback : func;
289
290
}

sletz's avatar
Cleanup    
sletz committed
291
292
EXPORT jack_client_t* jack_client_new(const char* client_name)
{
sletz's avatar
sletz committed
293
294
295
#ifdef __CLIENTDEBUG__
    JackGlobals::CheckContext("jack_client_new");
#endif
296
297
298
299
300
301
302
    try {
        assert(JackGlobals::fOpenMutex);
        JackGlobals::fOpenMutex->Lock();
        jack_error("jack_client_new: deprecated");
        int options = JackUseExactName;
        if (getenv("JACK_START_SERVER") == NULL)
            options |= JackNoStartServer;
sletz's avatar
sletz committed
303
        jack_client_t* res = jack_client_new_aux(client_name, (jack_options_t)options, NULL);
304
305
306
307
308
309
310
311
312
        JackGlobals::fOpenMutex->Unlock();
        return res;
    } catch (std::bad_alloc& e) {
        jack_error("Memory allocation error...");
        return NULL;
    } catch (...) {
        jack_error("Unknown error...");
        return NULL;
    }
sletz's avatar
Cleanup    
sletz committed
313
314
}

sletz's avatar
sletz committed
315
316
EXPORT void* jack_port_get_buffer(jack_port_t* port, jack_nframes_t frames)
{
317
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
318
    JackGlobals::CheckContext("jack_port_get_buffer");
319
#endif
sletz's avatar
sletz committed
320
    uintptr_t port_aux = (uintptr_t)port;
321
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
322
323
324
325
    if (!CheckPort(myport)) {
        jack_error("jack_port_get_buffer called with an incorrect port %ld", myport);
        return NULL;
    } else {
sletz's avatar
sletz committed
326
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
327
        return (manager ? manager->GetBuffer(myport, frames) : NULL);
sletz's avatar
sletz committed
328
329
330
331
332
    }
}

EXPORT const char* jack_port_name(const jack_port_t* port)
{
333
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
334
    JackGlobals::CheckContext("jack_port_name");
335
#endif
sletz's avatar
sletz committed
336
    uintptr_t port_aux = (uintptr_t)port;
337
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
338
339
340
341
    if (!CheckPort(myport)) {
        jack_error("jack_port_name called with an incorrect port %ld", myport);
        return NULL;
    } else {
sletz's avatar
sletz committed
342
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
343
        return (manager ? manager->GetPort(myport)->GetName() : NULL);
sletz's avatar
sletz committed
344
345
346
347
348
    }
}

EXPORT const char* jack_port_short_name(const jack_port_t* port)
{
349
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
350
    JackGlobals::CheckContext("jack_port_short_name");
351
#endif
sletz's avatar
sletz committed
352
    uintptr_t port_aux = (uintptr_t)port;
353
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
354
355
356
357
    if (!CheckPort(myport)) {
        jack_error("jack_port_short_name called with an incorrect port %ld", myport);
        return NULL;
    } else {
sletz's avatar
sletz committed
358
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
Cleanup    
sletz committed
359
        return (manager ? manager->GetPort(myport)->GetShortName() : NULL);
sletz's avatar
sletz committed
360
361
362
363
364
    }
}

EXPORT int jack_port_flags(const jack_port_t* port)
{
365
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
366
    JackGlobals::CheckContext("jack_port_flags");
367
#endif
sletz's avatar
sletz committed
368
    uintptr_t port_aux = (uintptr_t)port;
369
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
370
371
372
373
    if (!CheckPort(myport)) {
        jack_error("jack_port_flags called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
374
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
Cleanup    
sletz committed
375
        return (manager ? manager->GetPort(myport)->GetFlags() : -1);
sletz's avatar
sletz committed
376
377
378
379
380
    }
}

EXPORT const char* jack_port_type(const jack_port_t* port)
{
381
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
382
    JackGlobals::CheckContext("jack_port_type");
383
#endif
sletz's avatar
sletz committed
384
    uintptr_t port_aux = (uintptr_t)port;
385
386
    jack_port_id_t myport = (jack_port_id_t)port_aux;
   if (!CheckPort(myport)) {
sletz's avatar
sletz committed
387
388
389
        jack_error("jack_port_flags called an incorrect port %ld", myport);
        return NULL;
    } else {
sletz's avatar
sletz committed
390
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
Cleanup    
sletz committed
391
        return (manager ? manager->GetPort(myport)->GetType() : NULL);
sletz's avatar
sletz committed
392
393
394
    }
}

395
EXPORT jack_port_type_id_t jack_port_type_id(const jack_port_t *port)
sletz's avatar
sletz committed
396
397
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
398
    JackGlobals::CheckContext("jack_port_type_id");
sletz's avatar
sletz committed
399
#endif
sletz's avatar
sletz committed
400
    uintptr_t port_aux = (uintptr_t)port;
401
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
402
403
404
405
406
407
408
409
410
    if (!CheckPort(myport)) {
        jack_error("jack_port_type_id called an incorrect port %ld", myport);
        return 0;
    } else {
        JackGraphManager* manager = GetGraphManager();
        return (manager ? GetPortTypeId(manager->GetPort(myport)->GetType()) : 0);
    }
}

sletz's avatar
sletz committed
411
412
EXPORT int jack_port_connected(const jack_port_t* port)
{
413
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
414
    JackGlobals::CheckContext("jack_port_connected");
415
#endif
sletz's avatar
sletz committed
416
    uintptr_t port_aux = (uintptr_t)port;
417
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
418
419
420
421
422
    if (!CheckPort(myport)) {
        jack_error("jack_port_connected called with an incorrect port %ld", myport);
        return -1;
    } else {
        WaitGraphChange();
sletz's avatar
sletz committed
423
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
Cleanup    
sletz committed
424
        return (manager ? manager->GetConnectionsNum(myport) : -1);
sletz's avatar
sletz committed
425
426
427
    }
}

428
EXPORT int jack_port_connected_to(const jack_port_t* port, const char* port_name)
sletz's avatar
sletz committed
429
{
430
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
431
    JackGlobals::CheckContext("jack_port_connected_to");
432
#endif
sletz's avatar
sletz committed
433
    uintptr_t port_aux = (uintptr_t)port;
434
    jack_port_id_t src = (jack_port_id_t)port_aux;
435
436
    if (!CheckPort(src)) {
        jack_error("jack_port_connected_to called with an incorrect port %ld", src);
sletz's avatar
sletz committed
437
        return -1;
438
    } else if (port_name == NULL) {
sletz's avatar
sletz committed
439
440
441
442
        jack_error("jack_port_connected_to called with a NULL port name");
        return -1;
    } else {
        WaitGraphChange();
sletz's avatar
sletz committed
443
444
445
446
447
448
449
450
        JackGraphManager* manager = GetGraphManager();
        jack_port_id_t dst = (manager ? manager->GetPort(port_name) : NO_PORT);
        if (dst == NO_PORT) {
            jack_error("Unknown destination port port_name = %s", port_name);
            return 0;
        } else {
            return manager->IsConnected(src, dst);
        }
sletz's avatar
sletz committed
451
452
453
454
455
    }
}

EXPORT int jack_port_tie(jack_port_t* src, jack_port_t* dst)
{
456
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
457
    JackGlobals::CheckContext("jack_port_tie");
458
#endif
sletz's avatar
sletz committed
459
    uintptr_t src_aux = (uintptr_t)src;
460
    jack_port_id_t mysrc = (jack_port_id_t)src_aux;
sletz's avatar
sletz committed
461
462
463
464
    if (!CheckPort(mysrc)) {
        jack_error("jack_port_tie called with a NULL src port");
        return -1;
    }
sletz's avatar
sletz committed
465
    uintptr_t dst_aux = (uintptr_t)dst;
466
    jack_port_id_t mydst = (jack_port_id_t)dst_aux;
sletz's avatar
sletz committed
467
468
469
470
    if (!CheckPort(mydst)) {
        jack_error("jack_port_tie called with a NULL dst port");
        return -1;
    }
sletz's avatar
sletz committed
471
472
    JackGraphManager* manager = GetGraphManager();
    if (manager && manager->GetPort(mysrc)->GetRefNum() != manager->GetPort(mydst)->GetRefNum()) {
sletz's avatar
sletz committed
473
474
        jack_error("jack_port_tie called with ports not belonging to the same client");
        return -1;
sletz's avatar
sletz committed
475
    } else {
sletz's avatar
sletz committed
476
477
        return manager->GetPort(mydst)->Tie(mysrc);
    }
sletz's avatar
sletz committed
478
479
480
481
}

EXPORT int jack_port_untie(jack_port_t* port)
{
482
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
483
    JackGlobals::CheckContext("jack_port_untie");
484
#endif
sletz's avatar
sletz committed
485
    uintptr_t port_aux = (uintptr_t)port;
486
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
487
488
489
490
    if (!CheckPort(myport)) {
        jack_error("jack_port_untie called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
491
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
492
        return (manager ? manager->GetPort(myport)->UnTie() : -1);
sletz's avatar
sletz committed
493
494
495
496
497
    }
}

EXPORT jack_nframes_t jack_port_get_latency(jack_port_t* port)
{
498
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
499
    JackGlobals::CheckContext("jack_port_get_latency");
500
#endif
sletz's avatar
sletz committed
501
    uintptr_t port_aux = (uintptr_t)port;
502
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
503
504
505
506
507
    if (!CheckPort(myport)) {
        jack_error("jack_port_get_latency called with an incorrect port %ld", myport);
        return 0;
    } else {
        WaitGraphChange();
sletz's avatar
sletz committed
508
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
509
        return (manager ? manager->GetPort(myport)->GetLatency() : 0);
sletz's avatar
sletz committed
510
511
512
513
514
    }
}

EXPORT void jack_port_set_latency(jack_port_t* port, jack_nframes_t frames)
{
515
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
516
    JackGlobals::CheckContext("jack_port_set_latency");
517
#endif
sletz's avatar
sletz committed
518
    uintptr_t port_aux = (uintptr_t)port;
519
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
520
521
522
    if (!CheckPort(myport)) {
        jack_error("jack_port_set_latency called with an incorrect port %ld", myport);
    } else {
sletz's avatar
sletz committed
523
524
525
        JackGraphManager* manager = GetGraphManager();
        if (manager)
            manager->GetPort(myport)->SetLatency(frames);
sletz's avatar
sletz committed
526
527
528
    }
}

529
EXPORT int jack_recompute_total_latency(jack_client_t* ext_client, jack_port_t* port)
sletz's avatar
sletz committed
530
531
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
532
    JackGlobals::CheckContext("jack_recompute_total_latency");
sletz's avatar
sletz committed
533
534
#endif

sletz's avatar
sletz committed
535
    JackClient* client = (JackClient*)ext_client;
sletz's avatar
sletz committed
536
    uintptr_t port_aux = (uintptr_t)port;
537
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
   
sletz committed
538
539
540
541
542
543
544
    if (client == NULL) {
        jack_error("jack_recompute_total_latencies called with a NULL client");
        return -1;
    } else if (!CheckPort(myport)) {
        jack_error("jack_recompute_total_latencies called with a NULL port");
        return -1;
    } else {
sletz's avatar
sletz committed
545
546
547
        WaitGraphChange();
        JackGraphManager* manager = GetGraphManager();
        return (manager ? manager->ComputeTotalLatency(myport) : -1);
sletz's avatar
   
sletz committed
548
    }
sletz's avatar
sletz committed
549
550
}

sletz's avatar
sletz committed
551
552
EXPORT int jack_recompute_total_latencies(jack_client_t* ext_client)
{
sletz's avatar
sletz committed
553
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
554
    JackGlobals::CheckContext("jack_recompute_total_latencies");
sletz's avatar
sletz committed
555
556
#endif

sletz's avatar
sletz committed
557
558
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
sletz's avatar
   
sletz committed
559
560
561
        jack_error("jack_recompute_total_latencies called with a NULL client");
        return -1;
    } else {
sletz's avatar
sletz committed
562
563
564
        WaitGraphChange();
        JackGraphManager* manager = GetGraphManager();
        return (manager ? manager->ComputeTotalLatencies() : -1);
sletz's avatar
   
sletz committed
565
    }
sletz's avatar
sletz committed
566
567
}

sletz's avatar
Cleanup    
sletz committed
568
569
570
571
/*
This is unsafe if case of concurrent access, and should be "serialized" doing a server call.
*/

sletz's avatar
sletz committed
572
573
EXPORT int jack_port_set_name(jack_port_t* port, const char* name)
{
574
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
575
    JackGlobals::CheckContext("jack_port_set_name");
576
#endif
sletz's avatar
sletz committed
577
    uintptr_t port_aux = (uintptr_t)port;
578
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
579
580
581
582
583
584
585
    if (!CheckPort(myport)) {
        jack_error("jack_port_set_name called with an incorrect port %ld", myport);
        return -1;
    } else if (name == NULL) {
        jack_error("jack_port_set_name called with a NULL port name");
        return -1;
    } else {
sletz's avatar
sletz committed
586
        JackGraphManager* manager = GetGraphManager();
587
588
        int refnum;
        if (manager && ((refnum = manager->GetPort(myport)->GetRefNum()) > 0)) {
589
            JackClient* client = JackGlobals::fClientTable[refnum];
590
591
592
593
594
            assert(client);
            return client->PortRename(myport, name);
        } else {
            return -1;
        }
sletz's avatar
sletz committed
595
596
597
    }
}

598
599
600
EXPORT int jack_port_set_alias(jack_port_t* port, const char* name)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
601
    JackGlobals::CheckContext("jack_port_set_alias");
602
#endif
sletz's avatar
sletz committed
603
    uintptr_t port_aux = (uintptr_t)port;
604
    jack_port_id_t myport = (jack_port_id_t)port_aux;
605
606
607
608
609
610
611
    if (!CheckPort(myport)) {
        jack_error("jack_port_set_alias called with an incorrect port %ld", myport);
        return -1;
    } else if (name == NULL) {
        jack_error("jack_port_set_alias called with a NULL port name");
        return -1;
    } else {
sletz's avatar
sletz committed
612
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
613
        return (manager ? manager->GetPort(myport)->SetAlias(name) : -1);
614
615
616
617
618
619
    }
}

EXPORT int jack_port_unset_alias(jack_port_t* port, const char* name)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
620
    JackGlobals::CheckContext("jack_port_unset_alias");
621
#endif
sletz's avatar
sletz committed
622
    uintptr_t port_aux = (uintptr_t)port;
623
    jack_port_id_t myport = (jack_port_id_t)port_aux;
624
625
626
627
628
629
630
    if (!CheckPort(myport)) {
        jack_error("jack_port_unset_alias called with an incorrect port %ld", myport);
        return -1;
    } else if (name == NULL) {
        jack_error("jack_port_unset_alias called with a NULL port name");
        return -1;
    } else {
sletz's avatar
sletz committed
631
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
632
        return (manager ? manager->GetPort(myport)->UnsetAlias(name) : -1);
633
634
635
636
637
638
    }
}

EXPORT int jack_port_get_aliases(const jack_port_t* port, char* const aliases[2])
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
639
    JackGlobals::CheckContext("jack_port_get_aliases");
640
#endif
sletz's avatar
sletz committed
641
    uintptr_t port_aux = (uintptr_t)port;
642
    jack_port_id_t myport = (jack_port_id_t)port_aux;
643
644
645
646
    if (!CheckPort(myport)) {
        jack_error("jack_port_get_aliases called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
647
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
648
        return (manager ? manager->GetPort(myport)->GetAliases(aliases) : -1);
649
650
651
    }
}

sletz's avatar
sletz committed
652
653
EXPORT int jack_port_request_monitor(jack_port_t* port, int onoff)
{
654
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
655
    JackGlobals::CheckContext("jack_port_request_monitor");
656
#endif
sletz's avatar
sletz committed
657
    uintptr_t port_aux = (uintptr_t)port;
658
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
659
660
661
662
    if (!CheckPort(myport)) {
        jack_error("jack_port_request_monitor called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
663
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
664
        return (manager ? manager->RequestMonitor(myport, onoff) : -1);
sletz's avatar
sletz committed
665
666
667
668
669
    }
}

EXPORT int jack_port_request_monitor_by_name(jack_client_t* ext_client, const char* port_name, int onoff)
{
670
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
671
    JackGlobals::CheckContext("jack_port_request_monitor_by_name");
672
#endif
sletz's avatar
sletz committed
673
674
675
676
677
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_port_request_monitor_by_name called with a NULL client");
        return -1;
    } else {
sletz's avatar
sletz committed
678
679
680
        JackGraphManager* manager = GetGraphManager();
        if (!manager)
            return -1;
sletz's avatar
sletz committed
681
        jack_port_id_t myport = manager->GetPort(port_name);
sletz's avatar
sletz committed
682
683
684
685
        if (!CheckPort(myport)) {
            jack_error("jack_port_request_monitor_by_name called with an incorrect port %s", port_name);
            return -1;
        } else {
sletz's avatar
sletz committed
686
            return manager->RequestMonitor(myport, onoff);
sletz's avatar
sletz committed
687
688
689
690
691
692
        }
    }
}

EXPORT int jack_port_ensure_monitor(jack_port_t* port, int onoff)
{
693
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
694
    JackGlobals::CheckContext("jack_port_ensure_monitor");
695
#endif
sletz's avatar
sletz committed
696
    uintptr_t port_aux = (uintptr_t)port;
697
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
698
699
700
701
    if (!CheckPort(myport)) {
        jack_error("jack_port_ensure_monitor called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
702
703
        JackGraphManager* manager = GetGraphManager();
        return (manager ? manager->GetPort(myport)->EnsureMonitor(onoff) : -1);
sletz's avatar
sletz committed
704
705
706
707
708
    }
}

EXPORT int jack_port_monitoring_input(jack_port_t* port)
{
709
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
710
    JackGlobals::CheckContext("jack_port_monitoring_input");
711
#endif
sletz's avatar
sletz committed
712
    uintptr_t port_aux = (uintptr_t)port;
713
    jack_port_id_t myport = (jack_port_id_t)port_aux;
sletz's avatar
sletz committed
714
715
716
717
    if (!CheckPort(myport)) {
        jack_error("jack_port_monitoring_input called with an incorrect port %ld", myport);
        return -1;
    } else {
sletz's avatar
sletz committed
718
        JackGraphManager* manager = GetGraphManager();
sletz's avatar
sletz committed
719
        return (manager ? manager->GetPort(myport)->MonitoringInput() : -1);
sletz's avatar
sletz committed
720
721
722
723
724
    }
}

EXPORT int jack_is_realtime(jack_client_t* ext_client)
{
725
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
726
    JackGlobals::CheckContext("jack_is_realtime");
727
#endif
sletz's avatar
sletz committed
728
729
730
731
732
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_is_realtime called with a NULL client");
        return -1;
    } else {
sletz's avatar
sletz committed
733
        JackEngineControl* control = GetEngineControl();
sletz's avatar
sletz committed
734
        return (control ? control->fRealTime : -1);
sletz's avatar
sletz committed
735
736
737
    }
}

738
EXPORT void jack_on_shutdown(jack_client_t* ext_client, JackShutdownCallback callback, void* arg)
sletz's avatar
sletz committed
739
{
740
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
741
    JackGlobals::CheckContext("jack_on_shutdown");
742
#endif
sletz's avatar
sletz committed
743
744
745
746
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_on_shutdown called with a NULL client");
    } else {
747
        client->OnShutdown(callback, arg);
sletz's avatar
sletz committed
748
749
750
    }
}

751
752
753
EXPORT void jack_on_info_shutdown(jack_client_t* ext_client, JackInfoShutdownCallback callback, void* arg)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
754
    JackGlobals::CheckContext("jack_on_info_shutdown");
755
756
757
758
759
760
761
762
763
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_on_info_shutdown called with a NULL client");
    } else {
        client->OnInfoShutdown(callback, arg);
    }
}

sletz's avatar
sletz committed
764
765
EXPORT int jack_set_process_callback(jack_client_t* ext_client, JackProcessCallback callback, void* arg)
{
766
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
767
    JackGlobals::CheckContext("jack_set_process_callback");
768
#endif
sletz's avatar
sletz committed
769
770
771
772
773
774
775
776
777
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_process_callback called with a NULL client");
        return -1;
    } else {
        return client->SetProcessCallback(callback, arg);
    }
}

778
779
780
EXPORT jack_nframes_t jack_thread_wait(jack_client_t* ext_client, int status)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
781
    JackGlobals::CheckContext("jack_thread_wait");
782
783
784
785
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_thread_wait called with a NULL client");
sletz's avatar
sletz committed
786
        return 0;
787
    } else {
788
        jack_error("jack_thread_wait: deprecated, use jack_cycle_wait/jack_cycle_signal");
sletz's avatar
sletz committed
789
        return 0;
790
791
792
    }
}

sletz's avatar
sletz committed
793
794
795
EXPORT jack_nframes_t jack_cycle_wait(jack_client_t* ext_client)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
796
    JackGlobals::CheckContext("jack_cycle_wait");
sletz's avatar
sletz committed
797
798
799
800
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_cycle_wait called with a NULL client");
sletz's avatar
sletz committed
801
        return 0;
sletz's avatar
sletz committed
802
803
804
805
806
807
808
809
    } else {
        return client->CycleWait();
    }
}

EXPORT void jack_cycle_signal(jack_client_t* ext_client, int status)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
810
    JackGlobals::CheckContext("jack_cycle_signal");
sletz's avatar
sletz committed
811
812
813
814
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_cycle_signal called with a NULL client");
sletz's avatar
sletz committed
815
    } else {
sletz's avatar
sletz committed
816
817
818
819
        client->CycleSignal(status);
    }
}

820
EXPORT int jack_set_process_thread(jack_client_t* ext_client, JackThreadCallback fun, void *arg)
821
822
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
823
    JackGlobals::CheckContext("jack_set_process_thread");
824
825
826
827
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_process_thread called with a NULL client");
sletz's avatar
sletz committed
828
829
        return -1;
    } else {
830
831
832
833
        return client->SetProcessThread(fun, arg);
    }
}

sletz's avatar
sletz committed
834
835
EXPORT int jack_set_freewheel_callback(jack_client_t* ext_client, JackFreewheelCallback freewheel_callback, void* arg)
{
836
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
837
    JackGlobals::CheckContext("jack_set_freewheel_callback");
838
#endif
sletz's avatar
sletz committed
839
840
841
842
843
844
845
846
847
848
849
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_freewheel_callback called with a NULL client");
        return -1;
    } else {
        return client->SetFreewheelCallback(freewheel_callback, arg);
    }
}

EXPORT int jack_set_freewheel(jack_client_t* ext_client, int onoff)
{
850
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
851
    JackGlobals::CheckContext("jack_set_freewheel");
852
#endif
sletz's avatar
sletz committed
853
854
855
856
857
858
859
860
861
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_freewheel called with a NULL client");
        return -1;
    } else {
        return client->SetFreeWheel(onoff);
    }
}

862
EXPORT int jack_set_buffer_size(jack_client_t* ext_client, jack_nframes_t buffer_size)
sletz's avatar
sletz committed
863
{
864
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
865
    JackGlobals::CheckContext("jack_set_buffer_size");
866
#endif
sletz's avatar
sletz committed
867
868
869
870
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_buffer_size called with a NULL client");
        return -1;
871
    } else if (!CheckBufferSize(buffer_size)) {
sletz's avatar
sletz committed
872
873
        return -1;
    } else {
874
        return client->SetBufferSize(buffer_size);
sletz's avatar
sletz committed
875
876
877
878
879
    }
}

EXPORT int jack_set_buffer_size_callback(jack_client_t* ext_client, JackBufferSizeCallback bufsize_callback, void* arg)
{
880
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
881
    JackGlobals::CheckContext("jack_set_buffer_size_callback");
882
#endif
sletz's avatar
sletz committed
883
884
885
886
887
888
889
890
891
892
893
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_buffer_size_callback called with a NULL client");
        return -1;
    } else {
        return client->SetBufferSizeCallback(bufsize_callback, arg);
    }
}

EXPORT int jack_set_sample_rate_callback(jack_client_t* ext_client, JackSampleRateCallback srate_callback, void* arg)
{
894
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
895
    JackGlobals::CheckContext("jack_set_sample_rate_callback");
896
#endif
sletz's avatar
sletz committed
897
898
899
900
901
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_sample_rate_callback called with a NULL client");
        return -1;
    } else {
902
        return client->SetSampleRateCallback(srate_callback, arg);
sletz's avatar
sletz committed
903
904
905
    }
}

906
907
908
EXPORT int jack_set_client_registration_callback(jack_client_t* ext_client, JackClientRegistrationCallback registration_callback, void* arg)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
909
    JackGlobals::CheckContext("jack_set_client_registration_callback");
910
911
912
913
914
915
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_client_registration_callback called with a NULL client");
        return -1;
    } else {
sletz's avatar
sletz committed
916
        return client->SetClientRegistrationCallback(registration_callback, arg);
917
918
919
    }
}

sletz's avatar
sletz committed
920
921
EXPORT int jack_set_port_registration_callback(jack_client_t* ext_client, JackPortRegistrationCallback registration_callback, void* arg)
{
922
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
923
    JackGlobals::CheckContext("jack_set_port_registration_callback");
924
#endif
sletz's avatar
sletz committed
925
926
927
928
929
930
931
932
933
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_port_registration_callback called with a NULL client");
        return -1;
    } else {
        return client->SetPortRegistrationCallback(registration_callback, arg);
    }
}

sletz's avatar
sletz committed
934
935
936
EXPORT int jack_set_port_connect_callback(jack_client_t* ext_client, JackPortConnectCallback portconnect_callback, void* arg)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
937
    JackGlobals::CheckContext("jack_set_port_connect_callback");
sletz's avatar
sletz committed
938
939
940
941
942
943
944
945
946
947
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_port_connect_callback called with a NULL client");
        return -1;
    } else {
        return client->SetPortConnectCallback(portconnect_callback, arg);
    }
}

948
949
950
EXPORT int jack_set_port_rename_callback(jack_client_t* ext_client, JackPortRenameCallback rename_callback, void* arg)
{
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
951
    JackGlobals::CheckContext("jack_set_port_rename_callback");
952
953
954
955
956
957
958
959
960
961
#endif
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_port_rename_callback called with a NULL client");
        return -1;
    } else {
        return client->SetPortRenameCallback(rename_callback, arg);
    }
}

sletz's avatar
sletz committed
962
963
EXPORT int jack_set_graph_order_callback(jack_client_t* ext_client, JackGraphOrderCallback graph_callback, void* arg)
{
964
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
965
    JackGlobals::CheckContext("jack_set_graph_order_callback");
966
#endif
sletz's avatar
sletz committed
967
    JackClient* client = (JackClient*)ext_client;
sletz's avatar
sletz committed
968
    jack_log("jack_set_graph_order_callback ext_client %x client %x ", ext_client, client);
sletz's avatar
sletz committed
969
970
971
972
973
974
975
976
    if (client == NULL) {
        jack_error("jack_set_graph_order_callback called with a NULL client");
        return -1;
    } else {
        return client->SetGraphOrderCallback(graph_callback, arg);
    }
}

sletz's avatar
sletz committed
977
EXPORT int jack_set_xrun_callback(jack_client_t* ext_client, JackXRunCallback xrun_callback, void* arg)
sletz's avatar
sletz committed
978
{
979
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
980
    JackGlobals::CheckContext("jack_set_xrun_callback");
981
#endif
sletz's avatar
sletz committed
982
983
984
985
986
    JackClient* client = (JackClient*)ext_client;
    if (client == NULL) {
        jack_error("jack_set_xrun_callback called with a NULL client");
        return -1;
    } else {
sletz's avatar
sletz committed
987
        return client->SetXRunCallback(xrun_callback, arg);
sletz's avatar
sletz committed
988
989
990
    }
}

sletz's avatar
sletz committed
991
EXPORT int jack_set_thread_init_callback(jack_client_t* ext_client, JackThreadInitCallback init_callback, void *arg)
sletz's avatar
sletz committed
992
{
993
#ifdef __CLIENTDEBUG__
sletz's avatar
sletz committed
994
    JackGlobals::CheckContext("jack_set_thread_init_callback");
995
#endif
sletz's avatar
sletz committed
996
    JackClient* client = (JackClient*)ext_client;
sletz's avatar
sletz committed
997
    jack_log("jack_set_thread_init_callback ext_client %x client %x ", ext_client, client);
sletz's avatar
sletz committed
998
999
1000
    if (client == NULL) {
        jack_error("jack_set_thread_init_callback called with a NULL client");
        return -1;
For faster browsing, not all history is shown. View entire blame