Jackdmp.cpp 18.9 KB
Newer Older
sletz's avatar
sletz committed
1
/*
sletz's avatar
sletz committed
2
Copyright (C) 2001 Paul Davis
sletz's avatar
sletz committed
3
Copyright (C) 2004-2008 Grame
sletz's avatar
sletz committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(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
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include <iostream>
#include <assert.h>
23
24
#include <cassert>
#include <csignal>
sletz's avatar
sletz committed
25
26
#include <sys/types.h>
#include <getopt.h>
27
28
#include <cstring>
#include <cstdio>
29
#include <list>
30

31
#include "types.h"
sletz's avatar
sletz committed
32
#include "jack.h"
sletz's avatar
sletz committed
33
34
#include "JackConstants.h"
#include "JackDriverLoader.h"
sletz's avatar
sletz committed
35

36
#if defined(JACK_DBUS) && defined(__linux__)
37
#include <dbus/dbus.h>
38
39
40
#include "audio_reserve.h"
#endif

sletz's avatar
sletz committed
41
/*
sletz's avatar
sletz committed
42
This is a simple port of the old jackdmp.cpp file to use the new Jack 2.0 control API. Available options for the server
sletz's avatar
sletz committed
43
44
45
46
are "hard-coded" in the source. A much better approach would be to use the control API to:
- dynamically retrieve available server parameters and then prepare to parse them
- get available drivers and their possible parameters, then prepare to parse them.
*/
sletz's avatar
sletz committed
47

48
#ifdef __APPLE__
49
#include <CoreFoundation/CFNotificationCenter.h>
50
#include <CoreFoundation/CoreFoundation.h>
51

sletz's avatar
sletz committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
static void notify_server_start(const char* server_name)
{
    // Send notification to be used in the JackRouter plugin
    CFStringRef ref = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
    CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
            CFSTR("com.grame.jackserver.start"),
            ref,
            NULL,
            kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
    CFRelease(ref);
}

static void notify_server_stop(const char* server_name)
{
    // Send notification to be used in the JackRouter plugin
sletz's avatar
sletz committed
67
    CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
sletz's avatar
sletz committed
68
69
70
71
72
73
74
    CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
            CFSTR("com.grame.jackserver.stop"),
            ref1,
            NULL,
            kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
    CFRelease(ref1);
}
sletz's avatar
sletz committed
75

sletz's avatar
sletz committed
76
77
78
79
80
81
82
83
#else

static void notify_server_start(const char* server_name)
{}
static void notify_server_stop(const char* server_name)
{}

#endif
sletz's avatar
sletz committed
84
85
86

static void copyright(FILE* file)
{
sletz's avatar
sletz committed
87
    fprintf(file, "jackdmp " VERSION "\n"
sletz's avatar
sletz committed
88
            "Copyright 2001-2005 Paul Davis and others.\n"
89
            "Copyright 2004-2011 Grame.\n"
sletz's avatar
sletz committed
90
91
92
            "jackdmp comes with ABSOLUTELY NO WARRANTY\n"
            "This is free software, and you are welcome to redistribute it\n"
            "under certain conditions; see the file COPYING for details\n");
sletz's avatar
sletz committed
93
94
}

sletz's avatar
sletz committed
95
static void usage(FILE* file)
sletz's avatar
sletz committed
96
{
sletz's avatar
sletz committed
97
    fprintf(file, "\n"
98
99
100
            "usage: jackdmp [ --no-realtime OR -r ]\n"
            "               [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
            "      (the two previous arguments are mutually exclusive. The default is --realtime)\n"
sletz's avatar
sletz committed
101
102
            "               [ --name OR -n server-name ]\n"
            "               [ --timeout OR -t client-timeout-in-msecs ]\n"
103
            "               [ --loopback OR -L loopback-port-number ]\n"
sletz's avatar
sletz committed
104
            "               [ --port-max OR -p maximum-number-of-ports]\n"
105
106
            "               [ --slave-backend OR -X slave-backend-name ]\n"
            "               [ --internal-client OR -I internal-client-name ]\n"
sletz's avatar
sletz committed
107
            "               [ --verbose OR -v ]\n"
108
109
110
#ifdef __linux__
            "               [ --clocksource OR -c [ c(ycle) | h(pet) | s(ystem) ]\n"
#endif
111
            "               [ --replace-registry ]\n"
sletz's avatar
sletz committed
112
113
114
115
            "               [ --silent OR -s ]\n"
            "               [ --sync OR -S ]\n"
            "               [ --temporary OR -T ]\n"
            "               [ --version OR -V ]\n"
116
            "         -d master-backend-name [ ... master-backend args ... ]\n"
117
#ifdef __APPLE__
sletz's avatar
sletz committed
118
            "               Available master backends may include: coreaudio, dummy, net or netone.\n\n"
119
#endif
120
#ifdef WIN32
sletz's avatar
sletz committed
121
            "               Available master backends may include: portaudio, dummy, net or netone.\n\n"
122
#endif
123
#ifdef __linux__
sletz's avatar
sletz committed
124
            "               Available master backends may include: alsa, dummy, freebob, firewire, net or netone.\n\n"
125
126
#endif
#if defined(__sun__) || defined(sun)
127
            "               Available master backends may include: boomer, oss, dummy or net.\n\n"
128
#endif
129
130
            "       jackdmp -d master-backend-name --help\n"
            "             to display options for each master backend\n\n");
sletz's avatar
sletz committed
131
132
}

sletz's avatar
sletz committed
133
134
135
136
137
// To put in the control.h interface??
static jackctl_driver_t *
jackctl_server_get_driver(
    jackctl_server_t *server,
    const char *driver_name)
sletz's avatar
sletz committed
138
{
sletz's avatar
sletz committed
139
    const JSList * node_ptr;
sletz's avatar
sletz committed
140

sletz's avatar
sletz committed
141
    node_ptr = jackctl_server_get_drivers_list(server);
sletz's avatar
sletz committed
142

sletz's avatar
sletz committed
143
144
145
146
147
148
    while (node_ptr)
    {
        if (strcmp(jackctl_driver_get_name((jackctl_driver_t *)node_ptr->data), driver_name) == 0)
        {
            return (jackctl_driver_t *)node_ptr->data;
        }
sletz's avatar
sletz committed
149

sletz's avatar
sletz committed
150
151
152
153
        node_ptr = jack_slist_next(node_ptr);
    }

    return NULL;
sletz's avatar
sletz committed
154
155
}

156
157
158
159
160
161
162
163
164
165
166
167
168
169
static jackctl_internal_t * jackctl_server_get_internal(jackctl_server_t *server, const char *internal_name)
{
    const JSList * node_ptr = jackctl_server_get_internals_list(server);

    while (node_ptr) {
        if (strcmp(jackctl_internal_get_name((jackctl_internal_t *)node_ptr->data), internal_name) == 0) {
            return (jackctl_internal_t *)node_ptr->data;
        }
        node_ptr = jack_slist_next(node_ptr);
    }

    return NULL;
}

sletz's avatar
sletz committed
170
171
172
173
static jackctl_parameter_t *
jackctl_get_parameter(
    const JSList * parameters_list,
    const char * parameter_name)
sletz's avatar
sletz committed
174
{
sletz's avatar
sletz committed
175
176
177
178
179
180
181
182
183
184
185
    while (parameters_list)
    {
        if (strcmp(jackctl_parameter_get_name((jackctl_parameter_t *)parameters_list->data), parameter_name) == 0)
        {
            return (jackctl_parameter_t *)parameters_list->data;
        }

        parameters_list = jack_slist_next(parameters_list);
    }

    return NULL;
sletz's avatar
sletz committed
186
187
188
189
}

int main(int argc, char* argv[])
{
sletz's avatar
sletz committed
190
191
192
    jackctl_server_t * server_ctl;
    const JSList * server_parameters;
    const char* server_name = "default";
193
    jackctl_driver_t * master_driver_ctl;
sletz's avatar
sletz committed
194
    jackctl_driver_t * loopback_driver_ctl = NULL;
195
    int replace_registry = 0;
196

197
    const char *options = "-d:X:I:P:uvshVrRL:STFl:t:mn:p:"
198
#ifdef __linux__
199
        "c:"
200
#endif
201
        ;
202

sletz's avatar
sletz committed
203
    struct option long_options[] = {
204
205
206
#ifdef __linux__
                                       { "clock-source", 1, 0, 'c' },
#endif
207
                                       { "loopback-driver", 1, 0, 'L' },
208
209
                                       { "audio-driver", 1, 0, 'd' },
                                       { "midi-driver", 1, 0, 'X' },
210
                                       { "internal-client", 1, 0, 'I' },
sletz's avatar
sletz committed
211
212
213
214
                                       { "verbose", 0, 0, 'v' },
                                       { "help", 0, 0, 'h' },
                                       { "port-max", 1, 0, 'p' },
                                       { "no-mlock", 0, 0, 'm' },
sletz's avatar
sletz committed
215
                                       { "name", 1, 0, 'n' },
sletz's avatar
sletz committed
216
217
                                       { "unlock", 0, 0, 'u' },
                                       { "realtime", 0, 0, 'R' },
218
                                       { "no-realtime", 0, 0, 'r' },
219
                                       { "replace-registry", 0, &replace_registry, 0 },
sletz's avatar
sletz committed
220
221
222
223
224
225
226
227
228
                                       { "loopback", 0, 0, 'L' },
                                       { "realtime-priority", 1, 0, 'P' },
                                       { "timeout", 1, 0, 't' },
                                       { "temporary", 0, 0, 'T' },
                                       { "version", 0, 0, 'V' },
                                       { "silent", 0, 0, 's' },
                                       { "sync", 0, 0, 'S' },
                                       { 0, 0, 0, 0 }
                                   };
229

sletz's avatar
sletz committed
230
    int i,opt = 0;
sletz's avatar
sletz committed
231
    int option_index = 0;
232
233
    char* master_driver_name = NULL;
    char** master_driver_args = NULL;
234
    int master_driver_nargs = 1;
235
    int do_mlock = 1;
236
    int do_unlock = 0;
237
    int loopback = 0;
sletz's avatar
sletz committed
238
239
240
241
    bool show_version = false;
    sigset_t signals;
    jackctl_parameter_t* param;
    union jackctl_parameter_value value;
sletz's avatar
sletz committed
242

243
244
245
246
    std::list<char*> internals_list;
    std::list<char*> slaves_list;
    std::list<char*>::iterator it;

247
248
249
250
    // Assume that we fail.
    int return_value = -1;
    bool notify_sent = false;

nedko's avatar
nedko committed
251
    copyright(stdout);
252
253
254
#if defined(JACK_DBUS) && defined(__linux__)
    server_ctl = jackctl_server_create(audio_acquire, audio_release);
#else
255
    server_ctl = jackctl_server_create(NULL, NULL);
256
#endif
sletz's avatar
sletz committed
257
    if (server_ctl == NULL) {
sletz's avatar
Cleanup    
sletz committed
258
        fprintf(stderr, "Failed to create server object\n");
sletz's avatar
sletz committed
259
260
        return -1;
    }
261

sletz's avatar
sletz committed
262
    server_parameters = jackctl_server_get_parameters(server_ctl);
263

sletz's avatar
sletz committed
264
    opterr = 0;
265
    while (!master_driver_name &&
sletz's avatar
sletz committed
266
267
268
269
            (opt = getopt_long(argc, argv, options,
                               long_options, &option_index)) != EOF) {
        switch (opt) {

270
        #ifdef __linux__
271
272
273
274
275
276
277
278
279
280
281
282
283
284
            case 'c':
                param = jackctl_get_parameter(server_parameters, "clock-source");
                if (param != NULL) {
                    if (tolower (optarg[0]) == 'h') {
                        value.ui = JACK_TIMER_HPET;
                        jackctl_parameter_set_value(param, &value);
                    } else if (tolower (optarg[0]) == 'c') {
                        value.ui = JACK_TIMER_CYCLE_COUNTER;
                        jackctl_parameter_set_value(param, &value);
                    } else if (tolower (optarg[0]) == 's') {
                        value.ui = JACK_TIMER_SYSTEM_CLOCK;
                        jackctl_parameter_set_value(param, &value);
                    } else {
                        usage(stdout);
285
                        goto destroy_server;
286
287
288
289
290
                    }
                }
                break;
        #endif

sletz's avatar
sletz committed
291
            case 'd':
292
                master_driver_name = optarg;
293
                break;
294

295
296
297
            case 'L':
                loopback = atoi(optarg);
                break;
sletz's avatar
sletz committed
298

299
            case 'X':
300
301
302
303
304
                slaves_list.push_back(optarg);
                break;

            case 'I':
                internals_list.push_back(optarg);
sletz's avatar
sletz committed
305
                break;
sletz's avatar
sletz committed
306

307
            case 'p':
sletz's avatar
sletz committed
308
309
310
311
312
                param = jackctl_get_parameter(server_parameters, "port-max");
                if (param != NULL) {
                    value.ui = atoi(optarg);
                    jackctl_parameter_set_value(param, &value);
                }
313
                break;
sletz's avatar
sletz committed
314

315
316
317
            case 'm':
                do_mlock = 0;
                break;
sletz's avatar
sletz committed
318

319
320
321
            case 'u':
                do_unlock = 1;
                break;
sletz's avatar
sletz committed
322
323

            case 'v':
sletz's avatar
sletz committed
324
325
326
327
328
                param = jackctl_get_parameter(server_parameters, "verbose");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
329
330
331
332
333
334
335
                break;

            case 's':
                jack_set_error_function(silent_jack_error_callback);
                break;

            case 'S':
sletz's avatar
sletz committed
336
337
338
339
340
                param = jackctl_get_parameter(server_parameters, "sync");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
341
342
343
344
                break;

            case 'n':
                server_name = optarg;
sletz's avatar
sletz committed
345
346
347
348
349
                param = jackctl_get_parameter(server_parameters, "name");
                if (param != NULL) {
                    strncpy(value.str, optarg, JACK_PARAM_STRING_MAX);
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
350
351
352
                break;

            case 'P':
sletz's avatar
sletz committed
353
354
355
356
357
                param = jackctl_get_parameter(server_parameters, "realtime-priority");
                if (param != NULL) {
                    value.i = atoi(optarg);
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
358
                break;
359

sletz's avatar
sletz committed
360
            case 'r':
361
                param = jackctl_get_parameter(server_parameters, "realtime");
sletz's avatar
sletz committed
362
                if (param != NULL) {
363
                    value.b = false;
sletz's avatar
sletz committed
364
365
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
366
367
                break;

sletz's avatar
sletz committed
368
            case 'R':
sletz's avatar
sletz committed
369
370
371
372
373
                param = jackctl_get_parameter(server_parameters, "realtime");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
374
375
376
                break;

            case 'T':
sletz's avatar
sletz committed
377
378
379
380
381
                param = jackctl_get_parameter(server_parameters, "temporary");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
382
383
384
                break;

            case 't':
sletz's avatar
sletz committed
385
386
387
388
389
                param = jackctl_get_parameter(server_parameters, "client-timeout");
                if (param != NULL) {
                    value.i = atoi(optarg);
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
390
391
392
                break;

            case 'V':
sletz's avatar
sletz committed
393
                show_version = true;
sletz's avatar
sletz committed
394
395
396
                break;

            default:
sletz's avatar
sletz committed
397
                fprintf(stderr, "unknown option character %c\n", optopt);
sletz's avatar
sletz committed
398
                /*fallthru*/
sletz's avatar
sletz committed
399

sletz's avatar
sletz committed
400
401
            case 'h':
                usage(stdout);
402
                goto destroy_server;
sletz's avatar
sletz committed
403
404
        }
    }
405

406
407
408
409
410
411
    // Long option with no letter so treated separately
    param = jackctl_get_parameter(server_parameters, "replace-registry");
    if (param != NULL) {
        value.b = replace_registry;
        jackctl_parameter_set_value(param, &value);
    }
412

sletz's avatar
sletz committed
413
    if (show_version) {
sletz's avatar
sletz committed
414
        printf( "jackdmp version " VERSION
nedko's avatar
nedko committed
415
416
417
418
                " tmpdir " jack_server_dir
                " protocol %d"
                "\n", JACK_PROTOCOL_VERSION);
        return -1;
sletz's avatar
sletz committed
419
    }
sletz's avatar
sletz committed
420

421
    if (!master_driver_name) {
sletz's avatar
sletz committed
422
        usage(stderr);
423
        goto destroy_server;
sletz's avatar
sletz committed
424
    }
sletz's avatar
sletz committed
425

426
    // Master driver
427
428
429
    master_driver_ctl = jackctl_server_get_driver(server_ctl, master_driver_name);
    if (master_driver_ctl == NULL) {
        fprintf(stderr, "Unknown driver \"%s\"\n", master_driver_name);
430
        goto destroy_server;
sletz's avatar
sletz committed
431
432
    }

sletz's avatar
sletz committed
433
434
435
436
437
    if (jackctl_driver_get_type(master_driver_ctl) != JackMaster) {
        fprintf(stderr, "Driver \"%s\" is not a master \n", master_driver_name);
        goto destroy_server;
    }

sletz's avatar
sletz committed
438
    if (optind < argc) {
439
        master_driver_nargs = 1 + argc - optind;
sletz's avatar
sletz committed
440
    } else {
441
        master_driver_nargs = 1;
sletz's avatar
sletz committed
442
443
    }

444
    if (master_driver_nargs == 0) {
sletz's avatar
sletz committed
445
        fprintf(stderr, "No driver specified ... hmm. JACK won't do"
sletz's avatar
sletz committed
446
                " anything when run like this.\n");
447
        goto destroy_server;
sletz's avatar
sletz committed
448
449
    }

450
451
    master_driver_args = (char **) malloc(sizeof(char *) * master_driver_nargs);
    master_driver_args[0] = master_driver_name;
sletz's avatar
sletz committed
452

453
454
    for (i = 1; i < master_driver_nargs; i++) {
        master_driver_args[i] = argv[optind++];
sletz's avatar
sletz committed
455
456
    }

457
    if (jackctl_parse_driver_params(master_driver_ctl, master_driver_nargs, master_driver_args)) {
458
        goto destroy_server;
sletz's avatar
sletz committed
459
    }
sletz's avatar
sletz committed
460

461
    // Setup signals
462
    signals = jackctl_setup_signals(0);
463

464
465
466
467
    // Open server
    if (! jackctl_server_open(server_ctl, master_driver_ctl)) {
        fprintf(stderr, "Failed to open server\n");
        goto destroy_server;
sletz's avatar
sletz committed
468
    }
sletz's avatar
sletz committed
469

470
    // Slave drivers
471
472
473
474
    for (it = slaves_list.begin(); it != slaves_list.end(); it++) {
        jackctl_driver_t * slave_driver_ctl = jackctl_server_get_driver(server_ctl, *it);
        if (slave_driver_ctl == NULL) {
            fprintf(stderr, "Unknown driver \"%s\"\n", *it);
475
            goto close_server;
476
        }
sletz's avatar
sletz committed
477
478
479
480
        if (jackctl_driver_get_type(slave_driver_ctl) != JackSlave) {
            fprintf(stderr, "Driver \"%s\" is not a slave \n", *it);
            goto close_server;
        }
Stephane Letz's avatar
Stephane Letz committed
481
482
        if (!jackctl_server_add_slave(server_ctl, slave_driver_ctl)) {
            fprintf(stderr, "Driver \"%s\" cannot be loaded\n", *it);
483
            goto close_server;
Stephane Letz's avatar
Stephane Letz committed
484
        }
485
    }
486

487
488
489
    // Loopback driver
    if (loopback > 0) {
        loopback_driver_ctl = jackctl_server_get_driver(server_ctl, "loopback");
490

491
492
493
494
495
496
497
        if (loopback_driver_ctl != NULL) {
            const JSList * loopback_parameters = jackctl_driver_get_parameters(loopback_driver_ctl);
            param = jackctl_get_parameter(loopback_parameters, "channels");
            if (param != NULL) {
                value.ui = loopback;
                jackctl_parameter_set_value(param, &value);
            }
Stephane Letz's avatar
Stephane Letz committed
498
499
            if (!jackctl_server_add_slave(server_ctl, loopback_driver_ctl)) {
                fprintf(stderr, "Driver \"loopback\" cannot be loaded\n");
500
                goto close_server;
Stephane Letz's avatar
Stephane Letz committed
501
            }
sletz's avatar
sletz committed
502
503
504
        } else {
            fprintf(stderr, "Driver \"loopback\" not found\n");
            goto close_server;
505
        }
506
507
508
509
510
511
    }

    // Start the server
    if (!jackctl_server_start(server_ctl)) {
        fprintf(stderr, "Failed to start server\n");
        goto close_server;
512
    }
513

514
    // Internal clients
515
516
517
518
    for (it = internals_list.begin(); it != internals_list.end(); it++) {
        jackctl_internal_t * internal_driver_ctl = jackctl_server_get_internal(server_ctl, *it);
        if (internal_driver_ctl == NULL) {
            fprintf(stderr, "Unknown internal \"%s\"\n", *it);
519
            goto stop_server;
520
        }
Stephane Letz's avatar
Stephane Letz committed
521
522
        if (!jackctl_server_load_internal(server_ctl, internal_driver_ctl)) {
            fprintf(stderr, "Internal client \"%s\" cannot be loaded\n", *it);
523
            goto stop_server;
Stephane Letz's avatar
Stephane Letz committed
524
        }
525
526
    }

sletz's avatar
sletz committed
527
    notify_server_start(server_name);
528
529
    notify_sent = true;
    return_value = 0;
sletz's avatar
sletz committed
530
531
532

    // Waits for signal
    jackctl_wait_signals(signals);
sletz's avatar
sletz committed
533

534
 stop_server:
sletz's avatar
sletz committed
535
    if (!jackctl_server_stop(server_ctl)) {
sletz's avatar
Cleanup    
sletz committed
536
        fprintf(stderr, "Cannot stop server...\n");
537
    }
sletz's avatar
sletz committed
538

539
 close_server:
sletz's avatar
sletz committed
540
    if (loopback > 0 && loopback_driver_ctl) {
sletz's avatar
sletz committed
541
542
543
544
545
        jackctl_server_remove_slave(server_ctl, loopback_driver_ctl);
    }
    // Slave drivers
    for (it = slaves_list.begin(); it != slaves_list.end(); it++) {
        jackctl_driver_t * slave_driver_ctl = jackctl_server_get_driver(server_ctl, *it);
sletz's avatar
sletz committed
546
547
        if (slave_driver_ctl)
            jackctl_server_remove_slave(server_ctl, slave_driver_ctl);
sletz's avatar
sletz committed
548
    }
sletz's avatar
sletz committed
549

sletz's avatar
sletz committed
550
551
552
    // Internal clients
    for (it = internals_list.begin(); it != internals_list.end(); it++) {
        jackctl_internal_t * internal_driver_ctl = jackctl_server_get_internal(server_ctl, *it);
sletz's avatar
sletz committed
553
554
        if (internal_driver_ctl)
            jackctl_server_unload_internal(server_ctl, internal_driver_ctl);
sletz's avatar
sletz committed
555
    }
556
    jackctl_server_close(server_ctl);
sletz's avatar
sletz committed
557

558
 destroy_server:
sletz's avatar
sletz committed
559
    jackctl_server_destroy(server_ctl);
560
561
562
    if (notify_sent) {
        notify_server_stop(server_name);
    }
563
    return return_value;
sletz's avatar
sletz committed
564
}