Merge branch 'master' into develop
[jack2.git] / common / JackFreewheelDriver.cpp
blobe5a87204bb5154217a52642ffa34176a74f079b7
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 // When used in "master" mode
31 int JackFreewheelDriver::Process()
33 jack_log("JackFreewheelDriver::Process master %lld", fEngineControl->fTimeOutUsecs);
34 JackDriver::CycleTakeBeginTime();
36 if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
38 // Resume connected clients in the graph
39 if (ResumeRefNum() < 0) {
40 jack_error("JackFreewheelDriver::Process: ResumeRefNum error");
43 // Special "SuspendRefNum" with longer timeout
44 if (SuspendRefNum() < 0) { // Wait for all clients to finish for FREEWHEEL_DRIVER_TIMEOUT sec
45 jack_error("JackFreewheelDriver::Process: SuspendRefNum error");
48 } else { // Graph not finished: do not activate it
49 jack_error("JackFreewheelDriver::Process: Process error");
52 return 0;
55 // When used in "slave" mode
57 int JackFreewheelDriver::ProcessReadSync()
59 // Resume connected clients in the graph
60 if (ResumeRefNum() < 0) { // Signal all clients
61 jack_error("JackFreewheelDriver::ProcessReadSync: ResumeRefNum error");
62 return -1;
64 return 0;
67 int JackFreewheelDriver::ProcessWriteSync()
69 // Generic "SuspendRefNum" here
70 if (JackDriver::SuspendRefNum() < 0) {
71 jack_error("JackFreewheelDriver::ProcessSync: SuspendRefNum error");
72 return -1;
74 return 0;
77 int JackFreewheelDriver::ProcessReadAsync()
79 // Resume connected clients in the graph
80 if (ResumeRefNum() < 0) { // Signal all clients
81 jack_error("JackFreewheelDriver::ProcessReadAsync: ResumeRefNum error");
82 return -1;
84 return 0;
87 int JackFreewheelDriver::ProcessWriteAsync()
89 return 0;
92 int JackFreewheelDriver::SuspendRefNum()
94 return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000);
97 } // end of namespace