Collection of tools useful for audio production
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.

612 lines
21KB

  1. /*
  2. * Carla Backend
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.com>
  4. *
  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. * any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the COPYING file
  16. */
  17. #ifdef CARLA_ENGINE_JACK
  18. #include "carla_engine.h"
  19. #include "carla_plugin.h"
  20. #include <iostream>
  21. CARLA_BACKEND_START_NAMESPACE
  22. #if 0
  23. } /* adjust editor indent */
  24. #endif
  25. // -------------------------------------------------------------------------------------------------------------------
  26. // static JACK<->Engine calls
  27. static int carla_jack_srate_callback(jack_nframes_t newSampleRate, void* arg)
  28. {
  29. CarlaEngineJack* const engine = (CarlaEngineJack*)arg;
  30. engine->handleSampleRateCallback(newSampleRate);
  31. return 0;
  32. }
  33. static int carla_jack_bufsize_callback(jack_nframes_t newBufferSize, void* arg)
  34. {
  35. CarlaEngineJack* const engine = (CarlaEngineJack*)arg;
  36. engine->handleBufferSizeCallback(newBufferSize);
  37. return 0;
  38. }
  39. static void carla_jack_freewheel_callback(int starting, void* arg)
  40. {
  41. CarlaEngineJack* const engine = (CarlaEngineJack*)arg;
  42. engine->handleFreewheelCallback(bool(starting));
  43. }
  44. static int carla_jack_process_callback(jack_nframes_t nframes, void* arg)
  45. {
  46. CarlaEngineJack* const engine = (CarlaEngineJack*)arg;
  47. engine->handleProcessCallback(nframes);
  48. return 0;
  49. }
  50. static int carla_jack_process_callback_plugin(jack_nframes_t nframes, void* arg)
  51. {
  52. CarlaPlugin* const plugin = (CarlaPlugin*)arg;
  53. if (plugin && plugin->enabled())
  54. {
  55. plugin->engineProcessLock();
  56. plugin->initBuffers();
  57. plugin->process_jack(nframes);
  58. plugin->engineProcessUnlock();
  59. }
  60. return 0;
  61. }
  62. static void carla_jack_shutdown_callback(void* arg)
  63. {
  64. CarlaEngineJack* const engine = (CarlaEngineJack*)arg;
  65. engine->handleShutdownCallback();
  66. }
  67. // -------------------------------------------------------------------------------------------------------------------
  68. // Carla Engine (JACK)
  69. CarlaEngineJack::CarlaEngineJack()
  70. #ifdef Q_COMPILER_INITIALIZER_LISTS
  71. : CarlaEngine(),
  72. rackJackPorts{nullptr}
  73. #else
  74. : CarlaEngine()
  75. #endif
  76. {
  77. qDebug("CarlaEngineJack::CarlaEngineJack()");
  78. type = CarlaEngineTypeJack;
  79. client = nullptr;
  80. state = JackTransportStopped;
  81. freewheel = false;
  82. procThread = nullptr;
  83. memset(&pos, 0, sizeof(jack_position_t));
  84. #ifndef Q_COMPILER_INITIALIZER_LISTS
  85. for (unsigned short i=0; i < rackPortCount; i++)
  86. rackJackPorts[i] = nullptr;
  87. #endif
  88. }
  89. CarlaEngineJack::~CarlaEngineJack()
  90. {
  91. qDebug("CarlaEngineJack::~CarlaEngineJack()");
  92. }
  93. // -------------------------------------------------------------------------------------------------------------------
  94. bool CarlaEngineJack::init(const char* const clientName)
  95. {
  96. qDebug("CarlaEngineJack::init(\"%s\")", clientName);
  97. client = jack_client_open(clientName, JackNullOption, nullptr);
  98. state = JackTransportStopped;
  99. freewheel = false;
  100. procThread = nullptr;
  101. if (client)
  102. {
  103. sampleRate = jack_get_sample_rate(client);
  104. bufferSize = jack_get_buffer_size(client);
  105. jack_set_sample_rate_callback(client, carla_jack_srate_callback, this);
  106. jack_set_buffer_size_callback(client, carla_jack_bufsize_callback, this);
  107. jack_set_freewheel_callback(client, carla_jack_freewheel_callback, this);
  108. jack_set_process_callback(client, carla_jack_process_callback, this);
  109. jack_on_shutdown(client, carla_jack_shutdown_callback, this);
  110. #ifndef BUILD_BRIDGE
  111. if (carlaOptions.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
  112. {
  113. rackJackPorts[rackPortAudioIn1] = jack_port_register(client, "in1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
  114. rackJackPorts[rackPortAudioIn2] = jack_port_register(client, "in2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
  115. rackJackPorts[rackPortAudioOut1] = jack_port_register(client, "out1", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
  116. rackJackPorts[rackPortAudioOut2] = jack_port_register(client, "out2", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
  117. rackJackPorts[rackPortControlIn] = jack_port_register(client, "control-in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
  118. rackJackPorts[rackPortControlOut] = jack_port_register(client, "control-out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
  119. rackJackPorts[rackPortMidiIn] = jack_port_register(client, "midi-in", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput, 0);
  120. rackJackPorts[rackPortMidiOut] = jack_port_register(client, "midi-out", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput, 0);
  121. }
  122. #endif
  123. if (jack_activate(client) == 0)
  124. {
  125. // set client name, fixed for OSC usage
  126. // FIXME - put this in shared?
  127. char* fixedName = strdup(jack_get_client_name(client));
  128. for (size_t i=0; i < strlen(fixedName); i++)
  129. {
  130. if (! (std::isalpha(fixedName[i]) || std::isdigit(fixedName[i])))
  131. fixedName[i] = '_';
  132. }
  133. name = strdup(fixedName);
  134. free((void*)fixedName);
  135. CarlaEngine::init(name);
  136. return true;
  137. }
  138. else
  139. {
  140. setLastError("Failed to activate the JACK client");
  141. client = nullptr;
  142. }
  143. }
  144. else
  145. setLastError("Failed to create new JACK client");
  146. return false;
  147. }
  148. bool CarlaEngineJack::close()
  149. {
  150. qDebug("CarlaEngineJack::close()");
  151. CarlaEngine::close();
  152. if (name)
  153. {
  154. free((void*)name);
  155. name = nullptr;
  156. }
  157. if (jack_deactivate(client) == 0)
  158. {
  159. #ifndef BUILD_BRIDGE
  160. if (carlaOptions.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
  161. {
  162. jack_port_unregister(client, rackJackPorts[rackPortAudioIn1]);
  163. jack_port_unregister(client, rackJackPorts[rackPortAudioIn2]);
  164. jack_port_unregister(client, rackJackPorts[rackPortAudioOut1]);
  165. jack_port_unregister(client, rackJackPorts[rackPortAudioOut2]);
  166. jack_port_unregister(client, rackJackPorts[rackPortControlIn]);
  167. jack_port_unregister(client, rackJackPorts[rackPortControlOut]);
  168. jack_port_unregister(client, rackJackPorts[rackPortMidiIn]);
  169. jack_port_unregister(client, rackJackPorts[rackPortMidiOut]);
  170. }
  171. #endif
  172. if (jack_client_close(client) == 0)
  173. {
  174. client = nullptr;
  175. return true;
  176. }
  177. else
  178. setLastError("Failed to close the JACK client");
  179. }
  180. else
  181. setLastError("Failed to deactivate the JACK client");
  182. client = nullptr;
  183. return false;
  184. }
  185. bool CarlaEngineJack::isOnAudioThread()
  186. {
  187. return (QThread::currentThread() == procThread);
  188. }
  189. bool CarlaEngineJack::isOffline()
  190. {
  191. return freewheel;
  192. }
  193. bool CarlaEngineJack::isRunning()
  194. {
  195. return bool(client);
  196. }
  197. CarlaEngineClient* CarlaEngineJack::addClient(CarlaPlugin* const plugin)
  198. {
  199. CarlaEngineClientNativeHandle handle;
  200. #ifndef BUILD_BRIDGE
  201. if (carlaOptions.process_mode == PROCESS_MODE_SINGLE_CLIENT)
  202. {
  203. handle.client = client;
  204. }
  205. else if (carlaOptions.process_mode == PROCESS_MODE_MULTIPLE_CLIENTS)
  206. #endif
  207. {
  208. handle.client = jack_client_open(plugin->name(), JackNullOption, nullptr);
  209. jack_set_process_callback(handle.client, carla_jack_process_callback_plugin, plugin);
  210. }
  211. //else if (carla_options.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
  212. //{
  213. //}
  214. return new CarlaEngineClient(handle);
  215. }
  216. // -------------------------------------------------------------------------------------------------------------------
  217. void CarlaEngineJack::handleSampleRateCallback(double newSampleRate)
  218. {
  219. sampleRate = newSampleRate;
  220. }
  221. void CarlaEngineJack::handleBufferSizeCallback(uint32_t newBufferSize)
  222. {
  223. #ifndef BUILD_BRIDGE
  224. if (carlaOptions.proccess_hp)
  225. return;
  226. #endif
  227. bufferSizeChanged(newBufferSize);
  228. }
  229. void CarlaEngineJack::handleFreewheelCallback(bool isFreewheel)
  230. {
  231. freewheel = isFreewheel;
  232. }
  233. void CarlaEngineJack::handleProcessCallback(uint32_t nframes)
  234. {
  235. if (procThread == nullptr)
  236. procThread = QThread::currentThread();
  237. state = jack_transport_query(client, &pos);
  238. timeInfo.playing = (state != JackTransportStopped);
  239. if (pos.unique_1 == pos.unique_2)
  240. {
  241. timeInfo.frame = pos.frame;
  242. timeInfo.time = pos.usecs;
  243. if (pos.valid & JackPositionBBT)
  244. {
  245. timeInfo.valid = CarlaEngineTimeBBT;
  246. timeInfo.bbt.bar = pos.bar;
  247. timeInfo.bbt.beat = pos.beat;
  248. timeInfo.bbt.tick = pos.tick;
  249. timeInfo.bbt.bar_start_tick = pos.bar_start_tick;
  250. timeInfo.bbt.beats_per_bar = pos.beats_per_bar;
  251. timeInfo.bbt.beat_type = pos.beat_type;
  252. timeInfo.bbt.ticks_per_beat = pos.ticks_per_beat;
  253. timeInfo.bbt.beats_per_minute = pos.beats_per_minute;
  254. }
  255. else
  256. timeInfo.valid = 0;
  257. }
  258. else
  259. {
  260. timeInfo.frame = 0;
  261. timeInfo.valid = 0;
  262. }
  263. #ifndef BUILD_BRIDGE
  264. if (carlaOptions.process_mode == PROCESS_MODE_SINGLE_CLIENT)
  265. {
  266. for (unsigned short i=0; i < MAX_PLUGINS; i++)
  267. {
  268. CarlaPlugin* const plugin = __getPlugin(i);
  269. if (plugin && plugin->enabled())
  270. {
  271. plugin->engineProcessLock();
  272. plugin->initBuffers();
  273. plugin->process_jack(nframes);
  274. plugin->engineProcessUnlock();
  275. }
  276. }
  277. }
  278. else if (carlaOptions.process_mode == PROCESS_MODE_CONTINUOUS_RACK)
  279. {
  280. // get buffers from jack
  281. float* audioIn1 = (float*)jack_port_get_buffer(rackJackPorts[rackPortAudioIn1], nframes);
  282. float* audioIn2 = (float*)jack_port_get_buffer(rackJackPorts[rackPortAudioIn2], nframes);
  283. float* audioOut1 = (float*)jack_port_get_buffer(rackJackPorts[rackPortAudioOut1], nframes);
  284. float* audioOut2 = (float*)jack_port_get_buffer(rackJackPorts[rackPortAudioOut2], nframes);
  285. void* controlIn = jack_port_get_buffer(rackJackPorts[rackPortControlIn], nframes);
  286. void* controlOut = jack_port_get_buffer(rackJackPorts[rackPortControlOut], nframes);
  287. void* midiIn = jack_port_get_buffer(rackJackPorts[rackPortMidiIn], nframes);
  288. void* midiOut = jack_port_get_buffer(rackJackPorts[rackPortMidiOut], nframes);
  289. // assert buffers
  290. Q_ASSERT(audioIn1);
  291. Q_ASSERT(audioIn2);
  292. Q_ASSERT(audioOut1);
  293. Q_ASSERT(audioOut2);
  294. Q_ASSERT(controlIn);
  295. Q_ASSERT(controlOut);
  296. Q_ASSERT(midiIn);
  297. Q_ASSERT(midiOut);
  298. // create temporary audio buffers
  299. float ains_tmp_buf1[nframes];
  300. float ains_tmp_buf2[nframes];
  301. float aouts_tmp_buf1[nframes];
  302. float aouts_tmp_buf2[nframes];
  303. float* ains_tmp[2] = { ains_tmp_buf1, ains_tmp_buf2 };
  304. float* aouts_tmp[2] = { aouts_tmp_buf1, aouts_tmp_buf2 };
  305. // initialize audio input
  306. memcpy(ains_tmp_buf1, audioIn1, sizeof(float)*nframes);
  307. memcpy(ains_tmp_buf2, audioIn2, sizeof(float)*nframes);
  308. // initialize control input
  309. memset(rackControlEventsIn, 0, sizeof(CarlaEngineControlEvent)*MAX_ENGINE_CONTROL_EVENTS);
  310. {
  311. jack_midi_event_t jackEvent;
  312. const uint32_t jackEventCount = jack_midi_get_event_count(controlIn);
  313. uint32_t carlaEventIndex = 0;
  314. for (uint32_t jackEventIndex=0; jackEventIndex < jackEventCount; jackEventIndex++)
  315. {
  316. if (jack_midi_event_get(&jackEvent, controlIn, jackEventIndex) != 0)
  317. continue;
  318. CarlaEngineControlEvent* const carlaEvent = &rackControlEventsIn[carlaEventIndex++];
  319. uint8_t midiStatus = jackEvent.buffer[0];
  320. uint8_t midiChannel = midiStatus & 0x0F;
  321. carlaEvent->time = jackEvent.time;
  322. carlaEvent->channel = midiChannel;
  323. if (MIDI_IS_STATUS_CONTROL_CHANGE(midiStatus))
  324. {
  325. uint8_t midiControl = jackEvent.buffer[1];
  326. if (MIDI_IS_CONTROL_BANK_SELECT(midiControl))
  327. {
  328. uint8_t midiBank = jackEvent.buffer[2];
  329. carlaEvent->type = CarlaEngineEventMidiBankChange;
  330. carlaEvent->value = midiBank;
  331. }
  332. else if (midiControl == MIDI_CONTROL_ALL_SOUND_OFF)
  333. {
  334. carlaEvent->type = CarlaEngineEventAllSoundOff;
  335. }
  336. else if (midiControl == MIDI_CONTROL_ALL_NOTES_OFF)
  337. {
  338. carlaEvent->type = CarlaEngineEventAllNotesOff;
  339. }
  340. else
  341. {
  342. uint8_t midiValue = jackEvent.buffer[2];
  343. carlaEvent->type = CarlaEngineEventControlChange;
  344. carlaEvent->controller = midiControl;
  345. carlaEvent->value = double(midiValue)/127;
  346. }
  347. }
  348. else if (MIDI_IS_STATUS_PROGRAM_CHANGE(midiStatus))
  349. {
  350. uint8_t midiProgram = jackEvent.buffer[1];
  351. carlaEvent->type = CarlaEngineEventMidiProgramChange;
  352. carlaEvent->value = midiProgram;
  353. }
  354. }
  355. }
  356. // initialize midi input
  357. memset(rackMidiEventsIn, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  358. {
  359. uint32_t i = 0, j = 0;
  360. jack_midi_event_t jackEvent;
  361. while (jack_midi_event_get(&jackEvent, midiIn, j++) == 0)
  362. {
  363. if (i == MAX_ENGINE_MIDI_EVENTS)
  364. break;
  365. if (jackEvent.size < 4)
  366. {
  367. rackMidiEventsIn[i].time = jackEvent.time;
  368. rackMidiEventsIn[i].size = jackEvent.size;
  369. memcpy(rackMidiEventsIn[i].data, jackEvent.buffer, jackEvent.size);
  370. i += 1;
  371. }
  372. }
  373. }
  374. // initialize outputs (zero)
  375. memset(aouts_tmp_buf1, 0, sizeof(float)*nframes);
  376. memset(aouts_tmp_buf2, 0, sizeof(float)*nframes);
  377. memset(rackControlEventsOut, 0, sizeof(CarlaEngineControlEvent)*MAX_ENGINE_CONTROL_EVENTS);
  378. memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  379. bool processed = false;
  380. // process plugins
  381. for (unsigned short i=0; i < MAX_PLUGINS; i++)
  382. {
  383. CarlaPlugin* const plugin = __getPlugin(i);
  384. if (plugin && plugin->enabled())
  385. {
  386. if (processed)
  387. {
  388. // initialize inputs (from previous outputs)
  389. memcpy(ains_tmp_buf1, aouts_tmp_buf1, sizeof(float)*nframes);
  390. memcpy(ains_tmp_buf2, aouts_tmp_buf2, sizeof(float)*nframes);
  391. memcpy(rackMidiEventsIn, rackMidiEventsOut, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  392. // initialize outputs (zero)
  393. memset(aouts_tmp_buf1, 0, sizeof(float)*nframes);
  394. memset(aouts_tmp_buf2, 0, sizeof(float)*nframes);
  395. memset(rackMidiEventsOut, 0, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  396. }
  397. // process
  398. plugin->engineProcessLock();
  399. plugin->initBuffers();
  400. if (carlaOptions.proccess_hp)
  401. {
  402. float* ains_buffer2[2];
  403. float* aouts_buffer2[2];
  404. for (uint32_t j=0; j < nframes; j += 8)
  405. {
  406. ains_buffer2[0] = ains_tmp_buf1 + j;
  407. ains_buffer2[1] = ains_tmp_buf2 + j;
  408. aouts_buffer2[0] = aouts_tmp_buf1 + j;
  409. aouts_buffer2[1] = aouts_tmp_buf2 + j;
  410. plugin->process(ains_buffer2, aouts_buffer2, 8, j);
  411. }
  412. }
  413. else
  414. plugin->process(ains_tmp, aouts_tmp, nframes);
  415. plugin->engineProcessUnlock();
  416. // if plugin has no audio inputs, add previous buffers
  417. if (plugin->audioInCount() == 0)
  418. {
  419. for (uint32_t j=0; j < nframes; j++)
  420. {
  421. aouts_tmp_buf1[j] += ains_tmp_buf1[j];
  422. aouts_tmp_buf2[j] += ains_tmp_buf2[j];
  423. }
  424. }
  425. // if plugin has no midi output, add previous midi input
  426. if (plugin->midiOutCount() == 0)
  427. {
  428. memcpy(rackMidiEventsOut, rackMidiEventsIn, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  429. }
  430. processed = true;
  431. }
  432. }
  433. // if no plugins in the rack, copy inputs over outputs
  434. if (! processed)
  435. {
  436. memcpy(aouts_tmp_buf1, ains_tmp_buf1, sizeof(float)*nframes);
  437. memcpy(aouts_tmp_buf2, ains_tmp_buf2, sizeof(float)*nframes);
  438. memcpy(rackMidiEventsOut, rackMidiEventsIn, sizeof(CarlaEngineMidiEvent)*MAX_ENGINE_MIDI_EVENTS);
  439. }
  440. // output audio
  441. memcpy(audioOut1, aouts_tmp_buf1, sizeof(float)*nframes);
  442. memcpy(audioOut2, aouts_tmp_buf2, sizeof(float)*nframes);
  443. // output control
  444. {
  445. jack_midi_clear_buffer(controlOut);
  446. for (unsigned short i=0; i < MAX_ENGINE_CONTROL_EVENTS; i++)
  447. {
  448. CarlaEngineControlEvent* const event = &rackControlEventsOut[i];
  449. if (event->type == CarlaEngineEventControlChange && MIDI_IS_CONTROL_BANK_SELECT(event->controller))
  450. event->type = CarlaEngineEventMidiBankChange;
  451. uint8_t data[4] = { 0 };
  452. switch (event->type)
  453. {
  454. case CarlaEngineEventNull:
  455. break;
  456. case CarlaEngineEventControlChange:
  457. data[0] = MIDI_STATUS_CONTROL_CHANGE + event->channel;
  458. data[1] = event->controller;
  459. data[2] = event->value * 127;
  460. jack_midi_event_write(controlOut, event->time, data, 3);
  461. break;
  462. case CarlaEngineEventMidiBankChange:
  463. data[0] = MIDI_STATUS_CONTROL_CHANGE + event->channel;
  464. data[1] = MIDI_CONTROL_BANK_SELECT;
  465. data[2] = event->value;
  466. jack_midi_event_write(controlOut, event->time, data, 3);
  467. break;
  468. case CarlaEngineEventMidiProgramChange:
  469. data[0] = MIDI_STATUS_PROGRAM_CHANGE + event->channel;
  470. data[1] = event->value;
  471. jack_midi_event_write(controlOut, event->time, data, 2);
  472. break;
  473. case CarlaEngineEventAllSoundOff:
  474. data[0] = MIDI_STATUS_CONTROL_CHANGE + event->channel;
  475. data[1] = MIDI_CONTROL_ALL_SOUND_OFF;
  476. jack_midi_event_write(controlOut, event->time, data, 2);
  477. break;
  478. case CarlaEngineEventAllNotesOff:
  479. data[0] = MIDI_STATUS_CONTROL_CHANGE + event->channel;
  480. data[1] = MIDI_CONTROL_ALL_NOTES_OFF;
  481. jack_midi_event_write(controlOut, event->time, data, 2);
  482. break;
  483. }
  484. }
  485. }
  486. // output midi
  487. {
  488. jack_midi_clear_buffer(midiOut);
  489. for (unsigned short i=0; i < MAX_ENGINE_MIDI_EVENTS; i++)
  490. {
  491. if (rackMidiEventsOut[i].size == 0)
  492. break;
  493. jack_midi_event_write(midiOut, rackMidiEventsOut[i].time, rackMidiEventsOut[i].data, rackMidiEventsOut[i].size);
  494. }
  495. }
  496. }
  497. #else
  498. Q_UNUSED(nframes);
  499. #endif
  500. }
  501. void CarlaEngineJack::handleShutdownCallback()
  502. {
  503. //for (unsigned short i=0; i < MAX_PLUGINS; i++)
  504. //{
  505. // FIXME
  506. //CarlaPlugin* plugin = CarlaPlugins[i];
  507. //if (plugin && plugin->id() == plugin_id)
  508. // plugin->jack_client = nullptr;
  509. //}
  510. client = nullptr;
  511. procThread = nullptr;
  512. callback(CALLBACK_QUIT, 0, 0, 0, 0.0);
  513. }
  514. CARLA_BACKEND_END_NAMESPACE
  515. #endif // CARLA_ENGINE_JACK