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.

659 lines
21KB

  1. /*
  2. Copyright (C) 2004-2006 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #include <iostream>
  16. #include <fstream>
  17. #include <assert.h>
  18. #include "JackEngine.h"
  19. #include "JackExternalClient.h"
  20. #include "JackEngineControl.h"
  21. #include "JackClientControl.h"
  22. #include "JackEngineTiming.h"
  23. #include "JackGlobals.h"
  24. #include "JackChannel.h"
  25. #include "JackSyncInterface.h"
  26. namespace Jack
  27. {
  28. JackEngine::JackEngine(JackGraphManager* manager, JackSynchro** table, JackEngineControl* control, JackSyncInterface* signal, bool sync, long time_out_ms, bool rt, long priority, bool ve)
  29. {
  30. fGraphManager = manager;
  31. fSynchroTable = table;
  32. fEngineControl = control;
  33. fEngineControl->fSyncMode = sync;
  34. fEngineControl->fTimeOutUsecs = time_out_ms * 1000;
  35. fEngineControl->fRealTime = rt;
  36. fEngineControl->fPriority = priority;
  37. fEngineControl->fVerbose = ve;
  38. fChannel = JackGlobals::MakeServerNotifyChannel();
  39. fEngineTiming = new JackEngineTiming(fClientTable, fGraphManager, fEngineControl);
  40. fSignal = signal;
  41. for (int i = 0; i < CLIENT_NUM; i++)
  42. fClientTable[i] = NULL;
  43. fEngineTiming->ClearTimeMeasures();
  44. fEngineTiming->ResetRollingUsecs();
  45. }
  46. JackEngine::~JackEngine()
  47. {
  48. delete fChannel;
  49. delete fEngineTiming;
  50. }
  51. //-------------------
  52. // Client management
  53. //-------------------
  54. int JackEngine::Open()
  55. {
  56. JackLog("JackEngine::Open\n");
  57. // Open audio thread => request thread communication channel
  58. if (fChannel->Open() < 0) {
  59. jack_error("Cannot connect to server");
  60. return -1;
  61. } else {
  62. return 0;
  63. }
  64. }
  65. int JackEngine::Close()
  66. {
  67. JackLog("JackEngine::Close\n");
  68. fChannel->Close();
  69. // Close (possibly) remaining clients (RT is stopped)
  70. for (int i = 0; i < CLIENT_NUM; i++) {
  71. JackClientInterface* client = fClientTable[i];
  72. if (client) {
  73. JackLog("JackEngine::Close remaining client %ld\n", i);
  74. ClientCloseAux(i, client, false);
  75. client->Close();
  76. delete client;
  77. }
  78. }
  79. return 0;
  80. }
  81. int JackEngine::Allocate()
  82. {
  83. for (int i = 0; i < CLIENT_NUM; i++) {
  84. if (!fClientTable[i]) {
  85. JackLog("JackEngine::AllocateRefNum ref = %ld\n", i);
  86. return i;
  87. }
  88. }
  89. return -1;
  90. }
  91. //------------------
  92. // Graph management
  93. //------------------
  94. bool JackEngine::Process(jack_time_t callback_usecs)
  95. {
  96. bool res = true;
  97. // Transport
  98. //fEngineControl->fTransport.CycleBegin(fEngineControl->fSampleRate, callback_usecs);
  99. fEngineControl->CycleBegin(callback_usecs);
  100. // Timing
  101. //fEngineControl->fFrameTimer.IncFrameTime(fEngineControl->fBufferSize, callback_usecs, fEngineControl->fPeriodUsecs);
  102. fEngineControl->IncFrameTime(callback_usecs);
  103. fEngineTiming->UpdateTiming(callback_usecs);
  104. // Graph
  105. if (fGraphManager->IsFinishedGraph()) {
  106. fLastSwitchUsecs = callback_usecs;
  107. if (fGraphManager->RunNextGraph()) // True if the graph actually switched to a new state
  108. fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kGraphOrderCallback, 0);
  109. fSignal->SignalAll(); // Signal for threads waiting for next cycle
  110. res = true;
  111. } else {
  112. JackLog("Process: graph not finished!\n");
  113. if (callback_usecs > fLastSwitchUsecs + fEngineControl->fTimeOutUsecs) {
  114. JackLog("Process: switch to next state %ld\n", long(callback_usecs - fLastSwitchUsecs));
  115. //RemoveZombifiedClients(callback_usecs); TODO
  116. fLastSwitchUsecs = callback_usecs;
  117. if (fGraphManager->RunNextGraph())
  118. fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kGraphOrderCallback, 0);
  119. fSignal->SignalAll(); // Signal for threads waiting for next cycle
  120. res = true;
  121. } else {
  122. JackLog("Process: waiting to switch %ld\n", long(callback_usecs - fLastSwitchUsecs));
  123. if (callback_usecs < fLastSwitchUsecs + 2 * fEngineControl->fPeriodUsecs) // Signal XRun only for the first failling cycle
  124. CheckXRun(callback_usecs);
  125. fGraphManager->RunCurrentGraph();
  126. res = false;
  127. }
  128. }
  129. // Transport
  130. //fEngineControl->fTransport.CycleEnd(fClientTable, fEngineControl->fSampleRate, fEngineControl->fBufferSize);
  131. fEngineControl->CycleEnd(fClientTable);
  132. return res;
  133. }
  134. /*
  135. Client that finish *after* the callback date are considered late even if their output buffers may have been
  136. correctly mixed in the time window: callbackUsecs <==> Read <==> Write.
  137. */
  138. void JackEngine::CheckXRun(jack_time_t callback_usecs) // REVOIR les conditions de fin
  139. {
  140. for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
  141. JackClientInterface* client = fClientTable[i];
  142. if (client && client->GetClientControl()->fActive) {
  143. JackClientTiming* timing = fGraphManager->GetClientTiming(i);
  144. jack_client_state_t status = timing->fStatus;
  145. jack_time_t finished_date = timing->fFinishedAt;
  146. if (status != NotTriggered && status != Finished) {
  147. jack_error("JackEngine::XRun: client = %s was not runned: state = %ld", client->GetClientControl()->fName, status);
  148. //fChannel->ClientNotify(i, kXRunCallback, 0); // Notify the failing client
  149. fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kXRunCallback, 0); // Notify all clients
  150. }
  151. if (status == Finished && (long)(finished_date - callback_usecs) > 0) {
  152. jack_error("JackEngine::XRun: client %s finished after current callback", client->GetClientControl()->fName);
  153. //fChannel->ClientNotify(i, kXRunCallback, 0); // Notify the failing client
  154. fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kXRunCallback, 0); // Notify all clients
  155. }
  156. }
  157. }
  158. }
  159. //---------------
  160. // Zombification
  161. //---------------
  162. bool JackEngine::IsZombie(JackClientInterface* client, jack_time_t current_time)
  163. {
  164. return ((current_time - fGraphManager->GetClientTiming(client->GetClientControl()->fRefNum)->fFinishedAt) > 2 * fEngineControl->fTimeOutUsecs); // A VERIFIER
  165. }
  166. // TODO : check what happens with looped sub-graph....
  167. void JackEngine::GetZombifiedClients(bool zombi_clients[CLIENT_NUM], jack_time_t current_time)
  168. {
  169. for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
  170. JackClientInterface* client1 = fClientTable[i];
  171. if (client1 && IsZombie(client1, current_time)) {
  172. JackLog("JackEngine::GetZombifiedClients: %s\n", client1->GetClientControl()->fName);
  173. zombi_clients[i] = true; // Assume client is dead
  174. // If another dead client is connected to the scanned one, then the scanned one is not the first of the dead subgraph
  175. for (int j = REAL_REFNUM; j < CLIENT_NUM; j++) {
  176. JackClientInterface* client2 = fClientTable[j];
  177. if (client2 && IsZombie(client2, current_time) && fGraphManager->IsDirectConnection(j, i)) {
  178. zombi_clients[i] = false;
  179. break;
  180. }
  181. }
  182. } else {
  183. zombi_clients[i] = false;
  184. }
  185. }
  186. }
  187. void JackEngine::RemoveZombifiedClients(jack_time_t current_time)
  188. {
  189. bool zombi_clients[CLIENT_NUM];
  190. GetZombifiedClients(zombi_clients, current_time);
  191. for (int i = REAL_REFNUM; i < CLIENT_NUM; i++) {
  192. if (zombi_clients[i] && !fClientTable[i]->GetClientControl()->fZombie) {
  193. fClientTable[i]->GetClientControl()->fZombie = true;
  194. JackLog("RemoveZombifiedCients: name = %s\n", fClientTable[i]->GetClientControl()->fName);
  195. fGraphManager->DirectDisconnect(FREEWHEEL_DRIVER_REFNUM, i);
  196. fGraphManager->DirectDisconnect(i, FREEWHEEL_DRIVER_REFNUM);
  197. fGraphManager->DisconnectAllPorts(i);
  198. fChannel->ClientNotify(i, JackNotifyChannelInterface::kZombifyClient, 0); // Signal engine
  199. }
  200. }
  201. }
  202. void JackEngine::ZombifyClient(int refnum)
  203. {
  204. NotifyClient(refnum, JackNotifyChannelInterface::kZombifyClient, false, 0);
  205. }
  206. //---------------
  207. // Notifications
  208. //---------------
  209. void JackEngine::NotifyClient(int refnum, int event, int sync, int value)
  210. {
  211. JackClientInterface* client = fClientTable[refnum];
  212. // The client may be notified by the RT thread while closing
  213. if (client && (client->ClientNotify(refnum, client->GetClientControl()->fName, event, sync, value) < 0)) {
  214. jack_error("NotifyClient fails name = %s event = %ld = val = %ld", client->GetClientControl()->fName, event, value);
  215. } else {
  216. JackLog("JackEngine::NotifyClient: client not available anymore\n");
  217. }
  218. }
  219. void JackEngine::NotifyClients(int event, int sync, int value)
  220. {
  221. for (int i = 0; i < CLIENT_NUM; i++) {
  222. JackClientInterface* client = fClientTable[i];
  223. if (client && (client->ClientNotify(i, client->GetClientControl()->fName, event, sync, value) < 0)) {
  224. jack_error("NotifyClient fails name = %s event = %ld = val = %ld", client->GetClientControl()->fName, event, value);
  225. }
  226. }
  227. }
  228. int JackEngine::NotifyAddClient(JackClientInterface* new_client, const char* name, int refnum)
  229. {
  230. // Notify existing clients of the new client and new client of existing clients.
  231. for (int i = 0; i < CLIENT_NUM; i++) {
  232. JackClientInterface* old_client = fClientTable[i];
  233. if (old_client) {
  234. if (old_client->ClientNotify(refnum, name, JackNotifyChannelInterface::kAddClient, true, 0) < 0)
  235. return -1;
  236. if (new_client->ClientNotify(i, old_client->GetClientControl()->fName, JackNotifyChannelInterface::kAddClient, true, 0) < 0)
  237. return -1;
  238. }
  239. }
  240. return 0;
  241. }
  242. void JackEngine::NotifyRemoveClient(const char* name, int refnum)
  243. {
  244. // Notify existing clients (including the one beeing suppressed) of the removed client
  245. for (int i = 0; i < CLIENT_NUM; i++) {
  246. JackClientInterface* client = fClientTable[i];
  247. if (client) {
  248. client->ClientNotify(refnum, name, JackNotifyChannelInterface::kRemoveClient, true, 0);
  249. }
  250. }
  251. }
  252. // Coming from the driver
  253. void JackEngine::NotifyXRun(jack_time_t callback_usecs)
  254. {
  255. // Use the audio thread => request thread communication channel
  256. //fEngineControl->fFrameTimer.ResetFrameTime(fEngineControl->fSampleRate, callback_usecs, fEngineControl->fPeriodUsecs);
  257. fEngineControl->ResetFrameTime(callback_usecs);
  258. fChannel->ClientNotify(ALL_CLIENTS, JackNotifyChannelInterface::kXRunCallback, 0);
  259. }
  260. void JackEngine::NotifyXRun(int refnum)
  261. {
  262. if (refnum == ALL_CLIENTS) {
  263. NotifyClients(JackNotifyChannelInterface::kXRunCallback, false, 0);
  264. } else {
  265. NotifyClient(refnum, JackNotifyChannelInterface::kXRunCallback, false, 0);
  266. }
  267. }
  268. void JackEngine::NotifyGraphReorder()
  269. {
  270. NotifyClients(JackNotifyChannelInterface::kGraphOrderCallback, false, 0);
  271. }
  272. void JackEngine::NotifyBufferSize(jack_nframes_t nframes)
  273. {
  274. NotifyClients(JackNotifyChannelInterface::kBufferSizeCallback, true, nframes);
  275. }
  276. void JackEngine::NotifyFreewheel(bool onoff)
  277. {
  278. fEngineControl->fRealTime = !onoff;
  279. NotifyClients((onoff ? JackNotifyChannelInterface::kStartFreewheel : JackNotifyChannelInterface::kStopFreewheel), true, 0);
  280. }
  281. void JackEngine::NotifyPortRegistation(jack_port_id_t port_index, bool onoff)
  282. {
  283. NotifyClients((onoff ? JackNotifyChannelInterface::kPortRegistrationOn : JackNotifyChannelInterface::kPortRegistrationOff), false, port_index);
  284. }
  285. //-------------------
  286. // Client management
  287. //-------------------
  288. bool JackEngine::ClientCheckName(const char* name)
  289. {
  290. for (int i = 0; i < CLIENT_NUM; i++) {
  291. JackClientInterface* client = fClientTable[i];
  292. if (client && (strcmp(client->GetClientControl()->fName, name) == 0))
  293. return true;
  294. }
  295. return false;
  296. }
  297. // Used for external clients
  298. int JackEngine::ClientNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager)
  299. {
  300. if (ClientCheckName(name)) {
  301. jack_error("client %s already registered", name);
  302. return -1;
  303. }
  304. JackExternalClient* client = new JackExternalClient();
  305. if (ClientExternalNew(name, ref, shared_engine, shared_client, shared_graph_manager, client) < 0) {
  306. delete client;
  307. return -1;
  308. }
  309. return 0;
  310. }
  311. // Used for external clients
  312. int JackEngine::ClientExternalNew(const char* name, int* ref, int* shared_engine, int* shared_client, int* shared_graph_manager, JackExternalClient* client)
  313. {
  314. JackLog("JackEngine::ClientNew: name = %s \n", name);
  315. int refnum = Allocate();
  316. if (refnum < 0) {
  317. jack_error("No more refnum available");
  318. return -1;
  319. }
  320. if (!fSynchroTable[refnum]->Allocate(name, 0)) {
  321. jack_error("Cannot allocate synchro");
  322. goto error;
  323. }
  324. if (client->Open(name, refnum, shared_client) < 0) {
  325. jack_error("Cannot open client");
  326. goto error;
  327. }
  328. if (!fSignal->TimedWait(5 * 1000000)) {
  329. // Failure if RT thread is not running (problem with the driver...)
  330. jack_error("Driver is not running");
  331. goto error;
  332. }
  333. if (NotifyAddClient(client, name, refnum) < 0) {
  334. jack_error("Cannot notify add client");
  335. goto error;
  336. }
  337. fClientTable[refnum] = client;
  338. fGraphManager->InitRefNum(refnum);
  339. fEngineTiming->ResetRollingUsecs();
  340. *shared_engine = fEngineControl->GetShmIndex();
  341. *shared_graph_manager = fGraphManager->GetShmIndex();
  342. *ref = refnum;
  343. return 0;
  344. error:
  345. ClientCloseAux(refnum, client, false);
  346. client->Close();
  347. return -1;
  348. }
  349. // Used for server driver clients
  350. int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client)
  351. {
  352. JackLog("JackEngine::ClientInternalNew: name = %s\n", name);
  353. int refnum = Allocate();
  354. if (refnum < 0) {
  355. jack_error("No more refnum available");
  356. return -1;
  357. }
  358. if (!fSynchroTable[refnum]->Allocate(name, 0)) {
  359. jack_error("Cannot allocate synchro");
  360. return -1;
  361. }
  362. if (NotifyAddClient(client, name, refnum) < 0) {
  363. jack_error("Cannot notify add client");
  364. return -1;
  365. }
  366. fClientTable[refnum] = client;
  367. fGraphManager->InitRefNum(refnum);
  368. fEngineTiming->ResetRollingUsecs();
  369. *shared_engine = fEngineControl;
  370. *shared_manager = fGraphManager;
  371. *ref = refnum;
  372. return 0;
  373. }
  374. // Used for externall clients
  375. int JackEngine::ClientClose(int refnum)
  376. {
  377. JackClientInterface* client = fClientTable[refnum];
  378. if (client) {
  379. fEngineControl->fTransport.ResetTimebase(refnum);
  380. int res = ClientCloseAux(refnum, client, true);
  381. client->Close();
  382. delete client;
  383. return res;
  384. } else {
  385. return -1;
  386. }
  387. }
  388. // Used for server internal clients
  389. int JackEngine::ClientInternalClose(int refnum)
  390. {
  391. JackClientInterface* client = fClientTable[refnum];
  392. return (client) ? ClientCloseAux(refnum, client, true) : -1;
  393. }
  394. // Used for drivers that close when the RT thread is stopped
  395. int JackEngine::ClientInternalCloseIm(int refnum)
  396. {
  397. JackClientInterface* client = fClientTable[refnum];
  398. return (client) ? ClientCloseAux(refnum, client, false) : -1;
  399. }
  400. int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wait)
  401. {
  402. JackLog("JackEngine::ClientCloseAux ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  403. // Remove the client from the table
  404. fClientTable[refnum] = NULL;
  405. // Remove ports
  406. fGraphManager->RemoveAllPorts(refnum);
  407. // Wait until next cycle to be sure client is not used anymore
  408. if (wait) {
  409. if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 2)) { // Must wait at least until a switch occurs in Process, even in case of graph end failure
  410. JackLog("JackEngine::ClientCloseAux wait error ref = %ld \n", refnum);
  411. }
  412. }
  413. // Notify running clients
  414. NotifyRemoveClient(client->GetClientControl()->fName, client->GetClientControl()->fRefNum);
  415. // Cleanup...
  416. fSynchroTable[refnum]->Destroy();
  417. fEngineTiming->ResetRollingUsecs();
  418. return 0;
  419. }
  420. int JackEngine::ClientActivate(int refnum)
  421. {
  422. JackClientInterface* client = fClientTable[refnum];
  423. assert(fClientTable[refnum]);
  424. JackLog("JackEngine::ClientActivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  425. // Wait for graph state change to be effective
  426. if (!fSignal->TimedWait(fEngineControl->fPeriodUsecs * 10)) {
  427. JackLog("JackEngine::ClientActivate wait error ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  428. return -1;
  429. } else {
  430. return 0;
  431. }
  432. }
  433. // May be called without client
  434. int JackEngine::ClientDeactivate(int refnum)
  435. {
  436. JackClientInterface* client = fClientTable[refnum];
  437. if (client == NULL)
  438. return -1;
  439. JackLog("JackEngine::ClientDeactivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  440. fGraphManager->DisconnectAllPorts(refnum);
  441. // Wait for graph state change to be effective
  442. if (!fSignal->TimedWait(fEngineControl->fPeriodUsecs * 10)) {
  443. JackLog("JackEngine::ClientDeactivate wait error ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  444. return -1;
  445. } else {
  446. return 0;
  447. }
  448. }
  449. //-----------------
  450. // Port management
  451. //-----------------
  452. int JackEngine::PortRegister(int refnum, const char* name, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index)
  453. {
  454. JackLog("JackEngine::PortRegister ref = %ld name = %s flags = %d buffer_size = %d\n", refnum, name, flags, buffer_size);
  455. assert(fClientTable[refnum]);
  456. *port_index = fGraphManager->AllocatePort(refnum, name, (JackPortFlags)flags);
  457. if (*port_index != NO_PORT) {
  458. NotifyPortRegistation(*port_index, true);
  459. return 0;
  460. } else {
  461. return -1;
  462. }
  463. }
  464. int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index)
  465. {
  466. JackLog("JackEngine::PortUnRegister ref = %ld port_index = %ld\n", refnum, port_index);
  467. assert(fClientTable[refnum]);
  468. if (fGraphManager->RemovePort(refnum, port_index) == 0) {
  469. fGraphManager->ReleasePort(port_index);
  470. NotifyPortRegistation(port_index, false);
  471. return 0;
  472. } else {
  473. return -1;
  474. }
  475. }
  476. int JackEngine::PortConnect(int refnum, const char* src, const char* dst)
  477. {
  478. JackLog("JackEngine::PortConnect src = %s dst = %s\n", src, dst);
  479. jack_port_id_t port_src, port_dst;
  480. return (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0)
  481. ? -1
  482. : PortConnect(refnum, port_src, port_dst);
  483. }
  484. int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
  485. {
  486. JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst);
  487. jack_port_id_t port_src, port_dst;
  488. return (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0)
  489. ? -1
  490. : fGraphManager->Disconnect(port_src, port_dst);
  491. }
  492. int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  493. {
  494. JackLog("JackEngine::PortConnect src = %d dst = %d\n", src, dst);
  495. JackClientInterface* client;
  496. int ref;
  497. if (fGraphManager->CheckPorts(src, dst) < 0)
  498. return -1;
  499. ref = fGraphManager->GetOutputRefNum(src);
  500. assert(ref >= 0);
  501. client = fClientTable[ref];
  502. assert(client);
  503. if (!client->GetClientControl()->fActive) {
  504. jack_error("Cannot connect ports owned by inactive clients:"
  505. " \"%s\" is not active", client->GetClientControl()->fName);
  506. return -1;
  507. }
  508. ref = fGraphManager->GetInputRefNum(dst);
  509. assert(ref >= 0);
  510. client = fClientTable[ref];
  511. assert(client);
  512. if (!client->GetClientControl()->fActive) {
  513. jack_error("Cannot connect ports owned by inactive clients:"
  514. " \"%s\" is not active", client->GetClientControl()->fName);
  515. return -1;
  516. }
  517. return fGraphManager->Connect(src, dst);
  518. }
  519. int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  520. {
  521. JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst);
  522. if (dst == ALL_PORTS) {
  523. return (fGraphManager->CheckPort(src) < 0)
  524. ? -1
  525. : fGraphManager->DisconnectAll(src);
  526. } else {
  527. return (fGraphManager->CheckPorts(src, dst) < 0)
  528. ? -1
  529. : fGraphManager->Disconnect(src, dst);
  530. }
  531. }
  532. //----------------------
  533. // Transport management
  534. //----------------------
  535. int JackEngine::ReleaseTimebase(int refnum)
  536. {
  537. return fEngineControl->fTransport.ResetTimebase(refnum);
  538. }
  539. int JackEngine::SetTimebaseCallback(int refnum, int conditional)
  540. {
  541. return fEngineControl->fTransport.SetTimebase(refnum, conditional);
  542. }
  543. //-----------
  544. // Debugging
  545. //-----------
  546. void JackEngine::PrintState()
  547. {
  548. std::cout << "Engine State" << std::endl;
  549. for (int i = 0; i < CLIENT_NUM; i++) {
  550. JackClientInterface* client = fClientTable[i];
  551. if (client)
  552. std::cout << "Client : " << client->GetClientControl()->fName << " : " << i << std::endl;
  553. }
  554. //fGraphManager->PrintState();
  555. fEngineTiming->PrintState();
  556. }
  557. } // end of namespace