Hack JackWeakAPI.cpp for Windows (not tested.)
[jack2.git] / common / JackFreewheelDriver.cpp
blobc28e30c31915aac401d5b57495344eec47d00fd0
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "JackSystemDeps.h"
22 #include "JackFreewheelDriver.h"
23 #include "JackEngineControl.h"
24 #include "JackLockedEngine.h"
26 namespace Jack
29 int JackFreewheelDriver::Process()
31 if (fIsMaster) {
32 jack_log("JackFreewheelDriver::Process master %lld", fEngineControl->fTimeOutUsecs);
33 JackDriver::CycleTakeBeginTime();
34 fEngine->Process(fBeginDateUst, fEndDateUst);
35 fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients
36 if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000) < 0) { // Wait for all clients to finish for 10 sec
37 jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error");
38 /* We have a client time-out error, but still continue to process, until a better recovery strategy is chosen */
39 return 0;
41 } else {
42 fGraphManager->ResumeRefNum(&fClientControl, fSynchroTable); // Signal all clients
43 if (fEngineControl->fSyncMode) {
44 if (fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, DRIVER_TIMEOUT_FACTOR * fEngineControl->fTimeOutUsecs) < 0) {
45 jack_error("JackFreewheelDriver::ProcessSync SuspendRefNum error");
46 return -1;
50 return 0;
53 } // end of namespace