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.

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