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.

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