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.

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