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.

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