jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

689 lines
23KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004-2013 Grame
  4. Copyright (C) 2016-2022 Filipe Coelho
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #include <iostream>
  18. #include <assert.h>
  19. #include <cassert>
  20. #include <csignal>
  21. #include <sys/types.h>
  22. #include <getopt.h>
  23. #include <cstring>
  24. #include <cstdio>
  25. #include <list>
  26. #include "types.h"
  27. #include "jack.h"
  28. #include "control.h"
  29. #include "JackConstants.h"
  30. #include "JackPlatformPlug.h"
  31. #ifdef __ANDROID__
  32. #include "JackControlAPIAndroid.h"
  33. #endif
  34. #if defined(JACK_DBUS) && defined(__linux__)
  35. #include <cstdlib>
  36. #include <dbus/dbus.h>
  37. #include "audio_reserve.h"
  38. #endif
  39. #if HAVE_SYSTEMD
  40. #include <systemd/sd-daemon.h>
  41. #endif
  42. /*
  43. This is a simple port of the old jackdmp.cpp file to use the new jack2 control API. Available options for the server
  44. are "hard-coded" in the source. A much better approach would be to use the control API to:
  45. - dynamically retrieve available server parameters and then prepare to parse them
  46. - get available drivers and their possible parameters, then prepare to parse them.
  47. */
  48. #ifdef __APPLE__
  49. #include <CoreFoundation/CFNotificationCenter.h>
  50. #include <CoreFoundation/CoreFoundation.h>
  51. static void notify_server_start(const char* server_name)
  52. {
  53. // Send notification to be used in the JackRouter plugin
  54. CFStringRef ref = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
  55. CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
  56. CFSTR("com.grame.jackserver.start"),
  57. ref,
  58. NULL,
  59. kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
  60. CFRelease(ref);
  61. }
  62. static void notify_server_stop(const char* server_name)
  63. {
  64. // Send notification to be used in the JackRouter plugin
  65. CFStringRef ref1 = CFStringCreateWithCString(NULL, server_name, kCFStringEncodingMacRoman);
  66. CFNotificationCenterPostNotificationWithOptions(CFNotificationCenterGetDistributedCenter(),
  67. CFSTR("com.grame.jackserver.stop"),
  68. ref1,
  69. NULL,
  70. kCFNotificationDeliverImmediately | kCFNotificationPostToAllSessions);
  71. CFRelease(ref1);
  72. }
  73. #else
  74. static void notify_server_start(const char* server_name)
  75. {}
  76. static void notify_server_stop(const char* server_name)
  77. {}
  78. #endif
  79. static void copyright(FILE* file)
  80. {
  81. fprintf(file, "jackdmp " VERSION "\n"
  82. "Copyright 2001-2005 Paul Davis and others.\n"
  83. "Copyright 2004-2016 Grame.\n"
  84. "Copyright 2016-2022 Filipe Coelho.\n"
  85. "jackdmp comes with ABSOLUTELY NO WARRANTY\n"
  86. "This is free software, and you are welcome to redistribute it\n"
  87. "under certain conditions; see the file COPYING for details\n");
  88. }
  89. static jackctl_driver_t * jackctl_server_get_driver(jackctl_server_t *server, const char *driver_name)
  90. {
  91. const JSList * node_ptr = jackctl_server_get_drivers_list(server);
  92. while (node_ptr) {
  93. if (strcmp(jackctl_driver_get_name((jackctl_driver_t *)node_ptr->data), driver_name) == 0) {
  94. return (jackctl_driver_t *)node_ptr->data;
  95. }
  96. node_ptr = jack_slist_next(node_ptr);
  97. }
  98. return NULL;
  99. }
  100. static jackctl_internal_t * jackctl_server_get_internal(jackctl_server_t *server, const char *internal_name)
  101. {
  102. const JSList * node_ptr = jackctl_server_get_internals_list(server);
  103. while (node_ptr) {
  104. if (strcmp(jackctl_internal_get_name((jackctl_internal_t *)node_ptr->data), internal_name) == 0) {
  105. return (jackctl_internal_t *)node_ptr->data;
  106. }
  107. node_ptr = jack_slist_next(node_ptr);
  108. }
  109. return NULL;
  110. }
  111. static jackctl_parameter_t * jackctl_get_parameter(const JSList * parameters_list, const char * parameter_name)
  112. {
  113. while (parameters_list) {
  114. if (strcmp(jackctl_parameter_get_name((jackctl_parameter_t *)parameters_list->data), parameter_name) == 0) {
  115. return (jackctl_parameter_t *)parameters_list->data;
  116. }
  117. parameters_list = jack_slist_next(parameters_list);
  118. }
  119. return NULL;
  120. }
  121. #ifdef __ANDROID__
  122. static void jackctl_server_switch_master_dummy(jackctl_server_t * server_ctl, char * master_driver_name)
  123. {
  124. static bool is_dummy_driver = false;
  125. if(!strcmp(master_driver_name, "dummy")) {
  126. return;
  127. }
  128. jackctl_driver_t * driver_ctr;
  129. if(is_dummy_driver) {
  130. is_dummy_driver = false;
  131. driver_ctr = jackctl_server_get_driver(server_ctl, master_driver_name);
  132. } else {
  133. is_dummy_driver = true;
  134. driver_ctr = jackctl_server_get_driver(server_ctl, "dummy");
  135. }
  136. jackctl_server_switch_master(server_ctl, driver_ctr);
  137. }
  138. #endif
  139. static void print_server_drivers(jackctl_server_t *server, FILE* file)
  140. {
  141. const JSList * node_ptr = jackctl_server_get_drivers_list(server);
  142. fprintf(file, "Available backends:\n");
  143. while (node_ptr) {
  144. jackctl_driver_t* driver = (jackctl_driver_t *)node_ptr->data;
  145. fprintf(file, " %s (%s)\n", jackctl_driver_get_name(driver), (jackctl_driver_get_type(driver) == JackMaster) ? "master" : "slave");
  146. node_ptr = jack_slist_next(node_ptr);
  147. }
  148. fprintf(file, "\n");
  149. }
  150. static void print_server_internals(jackctl_server_t *server, FILE* file)
  151. {
  152. const JSList * node_ptr = jackctl_server_get_internals_list(server);
  153. fprintf(file, "Available internals:\n");
  154. while (node_ptr) {
  155. jackctl_internal_t* internal = (jackctl_internal_t *)node_ptr->data;
  156. fprintf(file, " %s\n", jackctl_internal_get_name(internal));
  157. node_ptr = jack_slist_next(node_ptr);
  158. }
  159. fprintf(file, "\n");
  160. }
  161. static void usage(FILE* file, jackctl_server_t *server, bool full = true)
  162. {
  163. jackctl_parameter_t * param;
  164. const JSList * server_parameters;
  165. uint32_t i;
  166. union jackctl_parameter_value value;
  167. fprintf(file, "\n"
  168. "Usage: jackdmp [ --no-realtime OR -r ]\n"
  169. " [ --realtime OR -R [ --realtime-priority OR -P priority ] ]\n"
  170. " (the two previous arguments are mutually exclusive. The default is --realtime)\n"
  171. " [ --name OR -n server-name ]\n"
  172. " [ --timeout OR -t client-timeout-in-msecs ]\n"
  173. " [ --loopback OR -L loopback-port-number ]\n"
  174. " [ --port-max OR -p maximum-number-of-ports]\n"
  175. " [ --slave-backend OR -X slave-backend-name ]\n"
  176. " [ --internal-client OR -I internal-client-name ]\n"
  177. " [ --internal-session-file OR -C internal-session-file ]\n"
  178. " [ --verbose OR -v ]\n"
  179. #ifdef __linux__
  180. " [ --clocksource OR -c [ h(pet) | s(ystem) ]\n"
  181. #endif
  182. " [ --autoconnect OR -a <modechar>]\n");
  183. server_parameters = jackctl_server_get_parameters(server);
  184. param = jackctl_get_parameter(server_parameters, "self-connect-mode");
  185. fprintf(file,
  186. " where <modechar> is one of:\n");
  187. for (i = 0; i < jackctl_parameter_get_enum_constraints_count(param); i++)
  188. {
  189. value = jackctl_parameter_get_enum_constraint_value(param, i);
  190. fprintf(file, " '%c' - %s", value.c, jackctl_parameter_get_enum_constraint_description(param, i));
  191. if (value.c == JACK_DEFAULT_SELF_CONNECT_MODE)
  192. {
  193. fprintf(file, " (default)");
  194. }
  195. fprintf(file, "\n");
  196. }
  197. fprintf(file,
  198. " [ --replace-registry ]\n"
  199. " [ --silent OR -s ]\n"
  200. " [ --sync OR -S ]\n"
  201. " [ --temporary OR -T ]\n"
  202. " [ --version OR -V ]\n"
  203. " -d master-backend-name [ ... master-backend args ... ]\n"
  204. " jackdmp -d master-backend-name --help\n"
  205. " to display options for each master backend\n\n");
  206. if (full) {
  207. print_server_drivers(server, file);
  208. print_server_internals(server, file);
  209. }
  210. }
  211. // Prototype to be found in libjackserver
  212. extern "C" void silent_jack_error_callback(const char *desc);
  213. void print_version()
  214. {
  215. printf( "jackdmp version " VERSION " tmpdir "
  216. jack_server_dir " protocol %d" "\n",
  217. JACK_PROTOCOL_VERSION);
  218. }
  219. int main(int argc, char** argv)
  220. {
  221. jackctl_server_t * server_ctl;
  222. const JSList * server_parameters;
  223. const char* server_name = JACK_DEFAULT_SERVER_NAME;
  224. jackctl_driver_t * master_driver_ctl;
  225. jackctl_driver_t * loopback_driver_ctl = NULL;
  226. int replace_registry = 0;
  227. for(int a = 1; a < argc; ++a) {
  228. if( !strcmp(argv[a], "--version") || !strcmp(argv[a], "-V") ) {
  229. print_version();
  230. return 0;
  231. }
  232. }
  233. const char *options = "-d:X:I:P:uvshrRL:STFl:t:mn:p:C:"
  234. "a:"
  235. #ifdef __linux__
  236. "c:"
  237. #endif
  238. ;
  239. struct option long_options[] = {
  240. #ifdef __linux__
  241. { "clock-source", 1, 0, 'c' },
  242. #endif
  243. { "internal-session-file", 1, 0, 'C' },
  244. { "loopback-driver", 1, 0, 'L' },
  245. { "audio-driver", 1, 0, 'd' },
  246. { "midi-driver", 1, 0, 'X' },
  247. { "internal-client", 1, 0, 'I' },
  248. { "verbose", 0, 0, 'v' },
  249. { "help", 0, 0, 'h' },
  250. { "port-max", 1, 0, 'p' },
  251. { "no-mlock", 0, 0, 'm' },
  252. { "name", 1, 0, 'n' },
  253. { "unlock", 0, 0, 'u' },
  254. { "realtime", 0, 0, 'R' },
  255. { "no-realtime", 0, 0, 'r' },
  256. { "replace-registry", 0, &replace_registry, 0 },
  257. { "loopback", 0, 0, 'L' },
  258. { "realtime-priority", 1, 0, 'P' },
  259. { "timeout", 1, 0, 't' },
  260. { "temporary", 0, 0, 'T' },
  261. { "silent", 0, 0, 's' },
  262. { "sync", 0, 0, 'S' },
  263. { "autoconnect", 1, 0, 'a' },
  264. { 0, 0, 0, 0 }
  265. };
  266. int i,opt = 0;
  267. int option_index = 0;
  268. char* internal_session_file = NULL;
  269. char* master_driver_name = NULL;
  270. char** master_driver_args = NULL;
  271. int master_driver_nargs = 1;
  272. int loopback = 0;
  273. jackctl_sigmask_t * sigmask;
  274. jackctl_parameter_t* param;
  275. union jackctl_parameter_value value;
  276. std::list<char*> internals_list;
  277. std::list<char*> slaves_list;
  278. std::list<char*>::iterator it;
  279. // Assume that we fail.
  280. int return_value = -1;
  281. bool notify_sent = false;
  282. copyright(stdout);
  283. #if defined(JACK_DBUS) && defined(__linux__)
  284. if (getenv("JACK_NO_AUDIO_RESERVATION"))
  285. server_ctl = jackctl_server_create2(NULL, NULL, NULL);
  286. else
  287. server_ctl = jackctl_server_create2(audio_acquire, audio_release, audio_reserve_loop);
  288. #else
  289. server_ctl = jackctl_server_create2(NULL, NULL, NULL);
  290. #endif
  291. if (server_ctl == NULL) {
  292. fprintf(stderr, "Failed to create server object\n");
  293. return -1;
  294. }
  295. server_parameters = jackctl_server_get_parameters(server_ctl);
  296. opterr = 0;
  297. while (!master_driver_name &&
  298. (opt = getopt_long(argc, argv, options,
  299. long_options, &option_index)) != EOF) {
  300. switch (opt) {
  301. #ifdef __linux__
  302. case 'c':
  303. param = jackctl_get_parameter(server_parameters, "clock-source");
  304. if (param != NULL) {
  305. if (tolower (optarg[0]) == 'h') {
  306. value.ui = JACK_TIMER_HPET;
  307. jackctl_parameter_set_value(param, &value);
  308. } else if (tolower (optarg[0]) == 'c') {
  309. /* For backwards compatibility with scripts, allow
  310. * the user to request the cycle clock on the
  311. * command line, but use the system clock instead
  312. */
  313. value.ui = JACK_TIMER_SYSTEM_CLOCK;
  314. jackctl_parameter_set_value(param, &value);
  315. } else if (tolower (optarg[0]) == 's') {
  316. value.ui = JACK_TIMER_SYSTEM_CLOCK;
  317. jackctl_parameter_set_value(param, &value);
  318. } else {
  319. usage(stdout, server_ctl);
  320. goto destroy_server;
  321. }
  322. }
  323. break;
  324. #endif
  325. case 'a':
  326. param = jackctl_get_parameter(server_parameters, "self-connect-mode");
  327. if (param != NULL) {
  328. bool value_valid = false;
  329. for (uint32_t k=0; k<jackctl_parameter_get_enum_constraints_count( param ); k++ ) {
  330. value = jackctl_parameter_get_enum_constraint_value( param, k );
  331. if( value.c == optarg[0] )
  332. value_valid = true;
  333. }
  334. if( value_valid ) {
  335. value.c = optarg[0];
  336. jackctl_parameter_set_value(param, &value);
  337. } else {
  338. usage(stdout, server_ctl);
  339. goto destroy_server;
  340. }
  341. }
  342. break;
  343. case 'd':
  344. master_driver_name = optarg;
  345. break;
  346. case 'L':
  347. loopback = atoi(optarg);
  348. break;
  349. case 'X':
  350. slaves_list.push_back(optarg);
  351. break;
  352. case 'I':
  353. internals_list.push_back(optarg);
  354. break;
  355. case 'p':
  356. param = jackctl_get_parameter(server_parameters, "port-max");
  357. if (param != NULL) {
  358. value.ui = atoi(optarg);
  359. jackctl_parameter_set_value(param, &value);
  360. }
  361. break;
  362. case 'm':
  363. break;
  364. case 'u':
  365. break;
  366. case 'v':
  367. param = jackctl_get_parameter(server_parameters, "verbose");
  368. if (param != NULL) {
  369. value.b = true;
  370. jackctl_parameter_set_value(param, &value);
  371. }
  372. break;
  373. case 's':
  374. jack_set_error_function(silent_jack_error_callback);
  375. break;
  376. case 'S':
  377. param = jackctl_get_parameter(server_parameters, "sync");
  378. if (param != NULL) {
  379. value.b = true;
  380. jackctl_parameter_set_value(param, &value);
  381. }
  382. break;
  383. case 'n':
  384. server_name = optarg;
  385. param = jackctl_get_parameter(server_parameters, "name");
  386. if (param != NULL) {
  387. strncpy(value.str, optarg, JACK_PARAM_STRING_MAX);
  388. jackctl_parameter_set_value(param, &value);
  389. }
  390. break;
  391. case 'C':
  392. internal_session_file = optarg;
  393. break;
  394. case 'P':
  395. param = jackctl_get_parameter(server_parameters, "realtime-priority");
  396. if (param != NULL) {
  397. value.i = atoi(optarg);
  398. jackctl_parameter_set_value(param, &value);
  399. }
  400. break;
  401. case 'r':
  402. param = jackctl_get_parameter(server_parameters, "realtime");
  403. if (param != NULL) {
  404. value.b = false;
  405. jackctl_parameter_set_value(param, &value);
  406. }
  407. break;
  408. case 'R':
  409. param = jackctl_get_parameter(server_parameters, "realtime");
  410. if (param != NULL) {
  411. value.b = true;
  412. jackctl_parameter_set_value(param, &value);
  413. }
  414. break;
  415. case 'T':
  416. param = jackctl_get_parameter(server_parameters, "temporary");
  417. if (param != NULL) {
  418. value.b = true;
  419. jackctl_parameter_set_value(param, &value);
  420. }
  421. break;
  422. case 't':
  423. param = jackctl_get_parameter(server_parameters, "client-timeout");
  424. if (param != NULL) {
  425. value.i = atoi(optarg);
  426. jackctl_parameter_set_value(param, &value);
  427. }
  428. break;
  429. case 'h':
  430. usage(stdout, server_ctl);
  431. return_value = 0;
  432. goto destroy_server;
  433. default:
  434. fprintf(stderr, "unknown option character %c\n", optopt);
  435. usage(stdout, server_ctl);
  436. goto destroy_server;
  437. }
  438. }
  439. // Long option with no letter so treated separately
  440. param = jackctl_get_parameter(server_parameters, "replace-registry");
  441. if (param != NULL) {
  442. value.b = replace_registry;
  443. jackctl_parameter_set_value(param, &value);
  444. }
  445. if (!master_driver_name) {
  446. usage(stderr, server_ctl, false);
  447. goto destroy_server;
  448. }
  449. // Master driver
  450. master_driver_ctl = jackctl_server_get_driver(server_ctl, master_driver_name);
  451. if (master_driver_ctl == NULL) {
  452. fprintf(stderr, "Unknown driver \"%s\"\n", master_driver_name);
  453. goto destroy_server;
  454. }
  455. if (jackctl_driver_get_type(master_driver_ctl) != JackMaster) {
  456. fprintf(stderr, "Driver \"%s\" is not a master \n", master_driver_name);
  457. goto destroy_server;
  458. }
  459. if (optind < argc) {
  460. master_driver_nargs = 1 + argc - optind;
  461. } else {
  462. master_driver_nargs = 1;
  463. }
  464. if (master_driver_nargs == 0) {
  465. fprintf(stderr, "No driver specified ... hmm. JACK won't do"
  466. " anything when run like this.\n");
  467. goto destroy_server;
  468. }
  469. master_driver_args = (char **) malloc(sizeof(char *) * master_driver_nargs);
  470. master_driver_args[0] = master_driver_name;
  471. for (i = 1; i < master_driver_nargs; i++) {
  472. master_driver_args[i] = argv[optind++];
  473. }
  474. if (jackctl_driver_params_parse(master_driver_ctl, master_driver_nargs, master_driver_args)) {
  475. goto destroy_server;
  476. }
  477. // Setup signals
  478. sigmask = jackctl_setup_signals(0);
  479. // Open server
  480. if (! jackctl_server_open(server_ctl, master_driver_ctl)) {
  481. fprintf(stderr, "Failed to open server\n");
  482. goto destroy_server;
  483. }
  484. // Slave drivers
  485. for (it = slaves_list.begin(); it != slaves_list.end(); it++) {
  486. jackctl_driver_t * slave_driver_ctl = jackctl_server_get_driver(server_ctl, *it);
  487. if (slave_driver_ctl == NULL) {
  488. fprintf(stderr, "Unknown driver \"%s\"\n", *it);
  489. goto close_server;
  490. }
  491. if (jackctl_driver_get_type(slave_driver_ctl) != JackSlave) {
  492. fprintf(stderr, "Driver \"%s\" is not a slave \n", *it);
  493. goto close_server;
  494. }
  495. if (!jackctl_server_add_slave(server_ctl, slave_driver_ctl)) {
  496. fprintf(stderr, "Driver \"%s\" cannot be loaded\n", *it);
  497. goto close_server;
  498. }
  499. }
  500. // Loopback driver
  501. if (loopback > 0) {
  502. loopback_driver_ctl = jackctl_server_get_driver(server_ctl, "loopback");
  503. if (loopback_driver_ctl != NULL) {
  504. const JSList * loopback_parameters = jackctl_driver_get_parameters(loopback_driver_ctl);
  505. param = jackctl_get_parameter(loopback_parameters, "channels");
  506. if (param != NULL) {
  507. value.ui = loopback;
  508. jackctl_parameter_set_value(param, &value);
  509. }
  510. if (!jackctl_server_add_slave(server_ctl, loopback_driver_ctl)) {
  511. fprintf(stderr, "Driver \"loopback\" cannot be loaded\n");
  512. goto close_server;
  513. }
  514. } else {
  515. fprintf(stderr, "Driver \"loopback\" not found\n");
  516. goto close_server;
  517. }
  518. }
  519. // Start the server
  520. if (!jackctl_server_start(server_ctl)) {
  521. fprintf(stderr, "Failed to start server\n");
  522. goto close_server;
  523. }
  524. // Internal clients
  525. for (it = internals_list.begin(); it != internals_list.end(); it++) {
  526. jackctl_internal_t * internal_driver_ctl = jackctl_server_get_internal(server_ctl, *it);
  527. if (internal_driver_ctl == NULL) {
  528. fprintf(stderr, "Unknown internal \"%s\"\n", *it);
  529. goto stop_server;
  530. }
  531. if (!jackctl_server_load_internal(server_ctl, internal_driver_ctl)) {
  532. fprintf(stderr, "Internal client \"%s\" cannot be loaded\n", *it);
  533. goto stop_server;
  534. }
  535. }
  536. if (internal_session_file != NULL) {
  537. if (!jackctl_server_load_session_file(server_ctl, internal_session_file)) {
  538. fprintf(stderr, "Internal session file %s cannot be loaded!\n", internal_session_file);
  539. goto stop_server;
  540. }
  541. }
  542. notify_server_start(server_name);
  543. notify_sent = true;
  544. return_value = 0;
  545. #if HAVE_SYSTEMD
  546. sd_notify(0, "READY=1");
  547. #endif
  548. // Waits for signal
  549. #ifdef __ANDROID__
  550. //reserve SIGUSR2 signal for switching master driver
  551. while(1) {
  552. int signal = jackctl_wait_signals_and_return(sigmask);
  553. if (signal == SIGUSR2) {
  554. jackctl_server_switch_master_dummy(server_ctl, master_driver_name);
  555. } else {
  556. break;
  557. }
  558. }
  559. #else
  560. jackctl_wait_signals(sigmask);
  561. #endif
  562. #if HAVE_SYSTEMD
  563. sd_notify(0, "STOPPING=1");
  564. #endif
  565. stop_server:
  566. if (!jackctl_server_stop(server_ctl)) {
  567. fprintf(stderr, "Cannot stop server...\n");
  568. }
  569. close_server:
  570. if (loopback > 0 && loopback_driver_ctl) {
  571. jackctl_server_remove_slave(server_ctl, loopback_driver_ctl);
  572. }
  573. // Slave drivers
  574. for (it = slaves_list.begin(); it != slaves_list.end(); it++) {
  575. jackctl_driver_t * slave_driver_ctl = jackctl_server_get_driver(server_ctl, *it);
  576. if (slave_driver_ctl) {
  577. jackctl_server_remove_slave(server_ctl, slave_driver_ctl);
  578. }
  579. }
  580. // Internal clients
  581. for (it = internals_list.begin(); it != internals_list.end(); it++) {
  582. jackctl_internal_t * internal_driver_ctl = jackctl_server_get_internal(server_ctl, *it);
  583. if (internal_driver_ctl) {
  584. jackctl_server_unload_internal(server_ctl, internal_driver_ctl);
  585. }
  586. }
  587. jackctl_server_close(server_ctl);
  588. destroy_server:
  589. jackctl_server_destroy(server_ctl);
  590. if (notify_sent) {
  591. notify_server_stop(server_name);
  592. }
  593. return return_value;
  594. }