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.

649 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 error1;
  309. }
  310. if (client->Open(name, refnum, shared_client) < 0) {
  311. jack_error("Cannot open client");
  312. goto error1;
  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 error2;
  318. }
  319. if (NotifyAddClient(client, name, refnum) < 0) {
  320. jack_error("Cannot notify add client");
  321. goto error2;
  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. error1:
  330. fGraphManager->ReleaseRefNum(refnum);
  331. return -1;
  332. error2:
  333. ClientCloseAux(refnum, client, false);
  334. client->Close();
  335. return -1;
  336. }
  337. // Used for server driver clients
  338. int JackEngine::ClientInternalNew(const char* name, int* ref, JackEngineControl** shared_engine, JackGraphManager** shared_manager, JackClientInterface* client)
  339. {
  340. JackLog("JackEngine::ClientInternalNew: name = %s\n", name);
  341. int refnum = fGraphManager->AllocateRefNum();
  342. if (refnum < 0) {
  343. jack_error("No more refnum available");
  344. return -1;
  345. }
  346. if (!fSynchroTable[refnum]->Allocate(name, 0)) {
  347. jack_error("Cannot allocate synchro");
  348. goto error;
  349. }
  350. if (NotifyAddClient(client, name, refnum) < 0) {
  351. jack_error("Cannot notify add client");
  352. goto error;
  353. }
  354. fClientTable[refnum] = client;
  355. fTiming->ResetRollingUsecs();
  356. *shared_engine = fEngineControl;
  357. *shared_manager = fGraphManager;
  358. *ref = refnum;
  359. return 0;
  360. error:
  361. fGraphManager->ReleaseRefNum(refnum);
  362. return -1;
  363. }
  364. // Used for externall clients
  365. int JackEngine::ClientClose(int refnum)
  366. {
  367. JackClientInterface* client = fClientTable[refnum];
  368. if (client) {
  369. fEngineControl->fTransport.ResetTimebase(refnum);
  370. int res = ClientCloseAux(refnum, client, true);
  371. client->Close();
  372. delete client;
  373. return res;
  374. } else {
  375. return -1;
  376. }
  377. }
  378. // Used for server internal clients
  379. int JackEngine::ClientInternalClose(int refnum)
  380. {
  381. JackClientInterface* client = fClientTable[refnum];
  382. return (client) ? ClientCloseAux(refnum, client, true) : -1;
  383. }
  384. // Used for drivers that close when the RT thread is stopped
  385. int JackEngine::ClientInternalCloseIm(int refnum)
  386. {
  387. JackClientInterface* client = fClientTable[refnum];
  388. return (client) ? ClientCloseAux(refnum, client, false) : -1;
  389. }
  390. int JackEngine::ClientCloseAux(int refnum, JackClientInterface* client, bool wait)
  391. {
  392. JackLog("JackEngine::ClientCloseAux ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  393. // Remove the client from the table
  394. fClientTable[refnum] = NULL;
  395. // Remove ports
  396. fGraphManager->RemoveAllPorts(refnum);
  397. // Wait until next cycle to be sure client is not used anymore
  398. if (wait) {
  399. if (!fSignal->TimedWait(fEngineControl->fTimeOutUsecs * 2)) { // Must wait at least until a switch occurs in Process, even in case of graph end failure
  400. JackLog("JackEngine::ClientCloseAux wait error ref = %ld \n", refnum);
  401. }
  402. }
  403. // Notify running clients
  404. NotifyRemoveClient(client->GetClientControl()->fName, client->GetClientControl()->fRefNum);
  405. // Cleanup...
  406. fSynchroTable[refnum]->Destroy();
  407. fGraphManager->ReleaseRefNum(refnum);
  408. fTiming->ResetRollingUsecs();
  409. return 0;
  410. }
  411. int JackEngine::ClientActivate(int refnum)
  412. {
  413. JackClientInterface* client = fClientTable[refnum];
  414. assert(fClientTable[refnum]);
  415. JackLog("JackEngine::ClientActivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  416. // Wait for graph state change to be effective
  417. if (!fSignal->TimedWait(fEngineControl->fPeriodUsecs * 10)) {
  418. JackLog("JackEngine::ClientActivate wait error ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  419. return -1;
  420. } else {
  421. return 0;
  422. }
  423. }
  424. // May be called without client
  425. int JackEngine::ClientDeactivate(int refnum)
  426. {
  427. JackClientInterface* client = fClientTable[refnum];
  428. if (client == NULL)
  429. return -1;
  430. JackLog("JackEngine::ClientDeactivate ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  431. fGraphManager->DisconnectAllPorts(refnum);
  432. // Wait for graph state change to be effective
  433. if (!fSignal->TimedWait(fEngineControl->fPeriodUsecs * 10)) {
  434. JackLog("JackEngine::ClientDeactivate wait error ref = %ld name = %s\n", refnum, client->GetClientControl()->fName);
  435. return -1;
  436. } else {
  437. return 0;
  438. }
  439. }
  440. //-----------------
  441. // Port management
  442. //-----------------
  443. int JackEngine::PortRegister(int refnum, const char* name, unsigned int flags, unsigned int buffer_size, jack_port_id_t* port_index)
  444. {
  445. JackLog("JackEngine::PortRegister ref = %ld name = %s flags = %d buffer_size = %d\n", refnum, name, flags, buffer_size);
  446. assert(fClientTable[refnum]);
  447. *port_index = fGraphManager->AllocatePort(refnum, name, (JackPortFlags)flags);
  448. if (*port_index != NO_PORT) {
  449. NotifyPortRegistation(*port_index, true);
  450. return 0;
  451. } else {
  452. return -1;
  453. }
  454. }
  455. int JackEngine::PortUnRegister(int refnum, jack_port_id_t port_index)
  456. {
  457. JackLog("JackEngine::PortUnRegister ref = %ld port_index = %ld\n", refnum, port_index);
  458. assert(fClientTable[refnum]);
  459. if (fGraphManager->RemovePort(refnum, port_index) == 0) {
  460. fGraphManager->ReleasePort(port_index);
  461. NotifyPortRegistation(port_index, false);
  462. return 0;
  463. } else {
  464. return -1;
  465. }
  466. }
  467. int JackEngine::PortConnect(int refnum, const char* src, const char* dst)
  468. {
  469. JackLog("JackEngine::PortConnect src = %s dst = %s\n", src, dst);
  470. jack_port_id_t port_src, port_dst;
  471. return (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0)
  472. ? -1
  473. : PortConnect(refnum, port_src, port_dst);
  474. }
  475. int JackEngine::PortDisconnect(int refnum, const char* src, const char* dst)
  476. {
  477. JackLog("JackEngine::PortDisconnect src = %s dst = %s\n", src, dst);
  478. jack_port_id_t port_src, port_dst;
  479. return (fGraphManager->CheckPorts(src, dst, &port_src, &port_dst) < 0)
  480. ? -1
  481. : fGraphManager->Disconnect(port_src, port_dst);
  482. }
  483. int JackEngine::PortConnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  484. {
  485. JackLog("JackEngine::PortConnect src = %d dst = %d\n", src, dst);
  486. JackClientInterface* client;
  487. int ref;
  488. if (fGraphManager->CheckPorts(src, dst) < 0)
  489. return -1;
  490. ref = fGraphManager->GetOutputRefNum(src);
  491. assert(ref >= 0);
  492. client = fClientTable[ref];
  493. assert(client);
  494. if (!client->GetClientControl()->fActive) {
  495. jack_error("Cannot connect ports owned by inactive clients:"
  496. " \"%s\" is not active", client->GetClientControl()->fName);
  497. return -1;
  498. }
  499. ref = fGraphManager->GetInputRefNum(dst);
  500. assert(ref >= 0);
  501. client = fClientTable[ref];
  502. assert(client);
  503. if (!client->GetClientControl()->fActive) {
  504. jack_error("Cannot connect ports owned by inactive clients:"
  505. " \"%s\" is not active", client->GetClientControl()->fName);
  506. return -1;
  507. }
  508. return fGraphManager->Connect(src, dst);
  509. }
  510. int JackEngine::PortDisconnect(int refnum, jack_port_id_t src, jack_port_id_t dst)
  511. {
  512. JackLog("JackEngine::PortDisconnect src = %d dst = %d\n", src, dst);
  513. if (dst == ALL_PORTS) {
  514. return (fGraphManager->CheckPort(src) < 0)
  515. ? -1
  516. : fGraphManager->DisconnectAll(src);
  517. } else {
  518. return (fGraphManager->CheckPorts(src, dst) < 0)
  519. ? -1
  520. : fGraphManager->Disconnect(src, dst);
  521. }
  522. }
  523. //----------------------
  524. // Transport management
  525. //----------------------
  526. int JackEngine::ReleaseTimebase(int refnum)
  527. {
  528. return fEngineControl->fTransport.ResetTimebase(refnum);
  529. }
  530. int JackEngine::SetTimebaseCallback(int refnum, int conditional)
  531. {
  532. return fEngineControl->fTransport.SetTimebase(refnum, conditional);
  533. }
  534. //-----------
  535. // Debugging
  536. //-----------
  537. void JackEngine::PrintState()
  538. {
  539. std::cout << "Engine State" << std::endl;
  540. for (int i = 0; i < CLIENT_NUM; i++) {
  541. JackClientInterface* client = fClientTable[i];
  542. if (client)
  543. std::cout << "Client : " << client->GetClientControl()->fName << " : " << i << std::endl;
  544. }
  545. //fGraphManager->PrintState();
  546. fTiming->PrintState();
  547. }
  548. } // end of namespace