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.

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