Jackdmp.cpp 18.8 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"
33
34
#include "control.h"

sletz's avatar
sletz committed
35
#include "JackConstants.h"
36
#include "JackPlatformPlug.h"
sletz's avatar
sletz committed
37

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

sletz's avatar
sletz committed
43
/*
sletz's avatar
sletz committed
44
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
45
46
47
48
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
49

50
#ifdef __APPLE__
51
#include <CoreFoundation/CFNotificationCenter.h>
52
#include <CoreFoundation/CoreFoundation.h>
53

sletz's avatar
sletz committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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
69
    CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
sletz's avatar
sletz committed
70
71
72
73
74
75
76
    CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
            CFSTR("com.grame.jackserver.stop"),
            ref1,
            NULL,
            kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
    CFRelease(ref1);
}
sletz's avatar
sletz committed
77

sletz's avatar
sletz committed
78
79
80
81
82
83
84
85
#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
86
87
88

static void copyright(FILE* file)
{
sletz's avatar
sletz committed
89
    fprintf(file, "jackdmp " VERSION "\n"
sletz's avatar
sletz committed
90
            "Copyright 2001-2005 Paul Davis and others.\n"
sletz's avatar
sletz committed
91
            "Copyright 2004-2012 Grame.\n"
sletz's avatar
sletz committed
92
93
94
            "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
95
96
}

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

135
136
// 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
137
{
138
    const JSList * node_ptr = jackctl_server_get_drivers_list(server);
sletz's avatar
sletz committed
139

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

    return NULL;
sletz's avatar
sletz committed
148
149
}

150
151
152
153
154
155
156
157
158
159
160
161
162
163
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;
}

164
static jackctl_parameter_t * jackctl_get_parameter(const JSList * parameters_list, const char * parameter_name)
sletz's avatar
sletz committed
165
{
166
167
    while (parameters_list) {
        if (strcmp(jackctl_parameter_get_name((jackctl_parameter_t *)parameters_list->data), parameter_name) == 0) {
sletz's avatar
sletz committed
168
169
170
171
172
173
            return (jackctl_parameter_t *)parameters_list->data;
        }
        parameters_list = jack_slist_next(parameters_list);
    }

    return NULL;
sletz's avatar
sletz committed
174
175
}

sletz's avatar
sletz committed
176
177
178
// Prototype to be found in libjackserver
extern "C" void silent_jack_error_callback(const char *desc);

179
int main(int argc, char** argv)
sletz's avatar
sletz committed
180
{
sletz's avatar
sletz committed
181
182
183
    jackctl_server_t * server_ctl;
    const JSList * server_parameters;
    const char* server_name = "default";
184
    jackctl_driver_t * master_driver_ctl;
sletz's avatar
sletz committed
185
    jackctl_driver_t * loopback_driver_ctl = NULL;
186
    int replace_registry = 0;
187

188
    const char *options = "-d:X:I:P:uvshVrRL:STFl:t:mn:p:"
189
#ifdef __linux__
190
        "c:"
191
#endif
192
        ;
193

sletz's avatar
sletz committed
194
    struct option long_options[] = {
195
196
197
#ifdef __linux__
                                       { "clock-source", 1, 0, 'c' },
#endif
198
                                       { "loopback-driver", 1, 0, 'L' },
199
200
                                       { "audio-driver", 1, 0, 'd' },
                                       { "midi-driver", 1, 0, 'X' },
201
                                       { "internal-client", 1, 0, 'I' },
sletz's avatar
sletz committed
202
203
204
205
                                       { "verbose", 0, 0, 'v' },
                                       { "help", 0, 0, 'h' },
                                       { "port-max", 1, 0, 'p' },
                                       { "no-mlock", 0, 0, 'm' },
sletz's avatar
sletz committed
206
                                       { "name", 1, 0, 'n' },
sletz's avatar
sletz committed
207
208
                                       { "unlock", 0, 0, 'u' },
                                       { "realtime", 0, 0, 'R' },
209
                                       { "no-realtime", 0, 0, 'r' },
210
                                       { "replace-registry", 0, &replace_registry, 0 },
sletz's avatar
sletz committed
211
212
213
214
215
216
217
218
219
                                       { "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 }
                                   };
220

sletz's avatar
sletz committed
221
    int i,opt = 0;
sletz's avatar
sletz committed
222
    int option_index = 0;
223
224
    char* master_driver_name = NULL;
    char** master_driver_args = NULL;
225
    int master_driver_nargs = 1;
226
    int loopback = 0;
sletz's avatar
sletz committed
227
    bool show_version = false;
228
    jackctl_sigmask_t * sigmask;
sletz's avatar
sletz committed
229
230
    jackctl_parameter_t* param;
    union jackctl_parameter_value value;
sletz's avatar
sletz committed
231

232
233
234
235
    std::list<char*> internals_list;
    std::list<char*> slaves_list;
    std::list<char*>::iterator it;

236
237
238
239
    // Assume that we fail.
    int return_value = -1;
    bool notify_sent = false;

nedko's avatar
nedko committed
240
    copyright(stdout);
241
242
243
#if defined(JACK_DBUS) && defined(__linux__)
    server_ctl = jackctl_server_create(audio_acquire, audio_release);
#else
244
    server_ctl = jackctl_server_create(NULL, NULL);
245
#endif
sletz's avatar
sletz committed
246
    if (server_ctl == NULL) {
sletz's avatar
Cleanup    
sletz committed
247
        fprintf(stderr, "Failed to create server object\n");
sletz's avatar
sletz committed
248
249
        return -1;
    }
250

sletz's avatar
sletz committed
251
    server_parameters = jackctl_server_get_parameters(server_ctl);
252

sletz's avatar
sletz committed
253
    opterr = 0;
254
    while (!master_driver_name &&
sletz's avatar
sletz committed
255
256
257
258
            (opt = getopt_long(argc, argv, options,
                               long_options, &option_index)) != EOF) {
        switch (opt) {

259
        #ifdef __linux__
260
261
262
263
264
265
266
267
268
269
270
271
272
273
            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);
274
                        goto destroy_server;
275
276
277
278
279
                    }
                }
                break;
        #endif

sletz's avatar
sletz committed
280
            case 'd':
281
                master_driver_name = optarg;
282
                break;
283

284
285
286
            case 'L':
                loopback = atoi(optarg);
                break;
sletz's avatar
sletz committed
287

288
            case 'X':
289
290
291
292
293
                slaves_list.push_back(optarg);
                break;

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

296
            case 'p':
sletz's avatar
sletz committed
297
298
299
300
301
                param = jackctl_get_parameter(server_parameters, "port-max");
                if (param != NULL) {
                    value.ui = atoi(optarg);
                    jackctl_parameter_set_value(param, &value);
                }
302
                break;
sletz's avatar
sletz committed
303

sletz's avatar
sletz committed
304
            case 'v':
sletz's avatar
sletz committed
305
306
307
308
309
                param = jackctl_get_parameter(server_parameters, "verbose");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
310
311
312
313
314
315
316
                break;

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

            case 'S':
sletz's avatar
sletz committed
317
318
319
320
321
                param = jackctl_get_parameter(server_parameters, "sync");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
322
323
324
325
                break;

            case 'n':
                server_name = optarg;
sletz's avatar
sletz committed
326
327
328
329
330
                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
331
332
333
                break;

            case 'P':
sletz's avatar
sletz committed
334
335
336
337
338
                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
339
                break;
340

sletz's avatar
sletz committed
341
            case 'r':
342
                param = jackctl_get_parameter(server_parameters, "realtime");
sletz's avatar
sletz committed
343
                if (param != NULL) {
344
                    value.b = false;
sletz's avatar
sletz committed
345
346
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
347
348
                break;

sletz's avatar
sletz committed
349
            case 'R':
sletz's avatar
sletz committed
350
351
352
353
354
                param = jackctl_get_parameter(server_parameters, "realtime");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
355
356
357
                break;

            case 'T':
sletz's avatar
sletz committed
358
359
360
361
362
                param = jackctl_get_parameter(server_parameters, "temporary");
                if (param != NULL) {
                    value.b = true;
                    jackctl_parameter_set_value(param, &value);
                }
sletz's avatar
sletz committed
363
364
365
                break;

            case 't':
sletz's avatar
sletz committed
366
367
368
369
370
                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
371
372
373
                break;

            case 'V':
sletz's avatar
sletz committed
374
                show_version = true;
sletz's avatar
sletz committed
375
376
377
                break;

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

sletz's avatar
sletz committed
381
382
            case 'h':
                usage(stdout);
383
                goto destroy_server;
sletz's avatar
sletz committed
384
385
        }
    }
386

387
388
389
390
391
392
    // 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);
    }
393

sletz's avatar
sletz committed
394
    if (show_version) {
sletz's avatar
sletz committed
395
        printf( "jackdmp version " VERSION
nedko's avatar
nedko committed
396
397
398
399
                " tmpdir " jack_server_dir
                " protocol %d"
                "\n", JACK_PROTOCOL_VERSION);
        return -1;
sletz's avatar
sletz committed
400
    }
sletz's avatar
sletz committed
401

402
    if (!master_driver_name) {
sletz's avatar
sletz committed
403
        usage(stderr);
404
        goto destroy_server;
sletz's avatar
sletz committed
405
    }
sletz's avatar
sletz committed
406

407
    // Master driver
408
409
410
    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);
411
        goto destroy_server;
sletz's avatar
sletz committed
412
413
    }

sletz's avatar
sletz committed
414
415
416
417
418
    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
419
    if (optind < argc) {
420
        master_driver_nargs = 1 + argc - optind;
sletz's avatar
sletz committed
421
    } else {
422
        master_driver_nargs = 1;
sletz's avatar
sletz committed
423
424
    }

425
    if (master_driver_nargs == 0) {
sletz's avatar
sletz committed
426
        fprintf(stderr, "No driver specified ... hmm. JACK won't do"
sletz's avatar
sletz committed
427
                " anything when run like this.\n");
428
        goto destroy_server;
sletz's avatar
sletz committed
429
430
    }

431
432
    master_driver_args = (char **) malloc(sizeof(char *) * master_driver_nargs);
    master_driver_args[0] = master_driver_name;
sletz's avatar
sletz committed
433

434
435
    for (i = 1; i < master_driver_nargs; i++) {
        master_driver_args[i] = argv[optind++];
sletz's avatar
sletz committed
436
437
    }

438
    if (jackctl_driver_params_parse(master_driver_ctl, master_driver_nargs, master_driver_args)) {
439
        goto destroy_server;
sletz's avatar
sletz committed
440
    }
sletz's avatar
sletz committed
441

442
    // Setup signals
443
    sigmask = jackctl_setup_signals(0);
444

445
446
447
448
    // 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
449
    }
sletz's avatar
sletz committed
450

451
    // Slave drivers
452
453
454
455
    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);
456
            goto close_server;
457
        }
sletz's avatar
sletz committed
458
459
460
461
        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
462
463
        if (!jackctl_server_add_slave(server_ctl, slave_driver_ctl)) {
            fprintf(stderr, "Driver \"%s\" cannot be loaded\n", *it);
464
            goto close_server;
Stephane Letz's avatar
Stephane Letz committed
465
        }
466
    }
467

468
469
470
    // Loopback driver
    if (loopback > 0) {
        loopback_driver_ctl = jackctl_server_get_driver(server_ctl, "loopback");
471

472
473
474
475
476
477
478
        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
479
480
            if (!jackctl_server_add_slave(server_ctl, loopback_driver_ctl)) {
                fprintf(stderr, "Driver \"loopback\" cannot be loaded\n");
481
                goto close_server;
Stephane Letz's avatar
Stephane Letz committed
482
            }
sletz's avatar
sletz committed
483
484
485
        } else {
            fprintf(stderr, "Driver \"loopback\" not found\n");
            goto close_server;
486
        }
487
488
489
490
491
492
    }

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

495
    // Internal clients
496
497
498
499
    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);
500
            goto stop_server;
501
        }
Stephane Letz's avatar
Stephane Letz committed
502
503
        if (!jackctl_server_load_internal(server_ctl, internal_driver_ctl)) {
            fprintf(stderr, "Internal client \"%s\" cannot be loaded\n", *it);
504
            goto stop_server;
Stephane Letz's avatar
Stephane Letz committed
505
        }
506
507
    }

sletz's avatar
sletz committed
508
    notify_server_start(server_name);
509
510
    notify_sent = true;
    return_value = 0;
sletz's avatar
sletz committed
511
512

    // Waits for signal
513
    jackctl_wait_signals(sigmask);
sletz's avatar
sletz committed
514

515
 stop_server:
sletz's avatar
sletz committed
516
    if (!jackctl_server_stop(server_ctl)) {
sletz's avatar
Cleanup    
sletz committed
517
        fprintf(stderr, "Cannot stop server...\n");
518
    }
sletz's avatar
sletz committed
519

520
 close_server:
sletz's avatar
sletz committed
521
    if (loopback > 0 && loopback_driver_ctl) {
sletz's avatar
sletz committed
522
523
524
525
526
        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
527
528
        if (slave_driver_ctl)
            jackctl_server_remove_slave(server_ctl, slave_driver_ctl);
sletz's avatar
sletz committed
529
    }
sletz's avatar
sletz committed
530

sletz's avatar
sletz committed
531
532
533
    // 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
534
535
        if (internal_driver_ctl)
            jackctl_server_unload_internal(server_ctl, internal_driver_ctl);
sletz's avatar
sletz committed
536
    }
537
    jackctl_server_close(server_ctl);
sletz's avatar
sletz committed
538

539
 destroy_server:
sletz's avatar
sletz committed
540
    jackctl_server_destroy(server_ctl);
541
542
543
    if (notify_sent) {
        notify_server_stop(server_name);
    }
544
    return return_value;
sletz's avatar
sletz committed
545
}