Jack2: JackFreewheelDriver.cpp Source File

Jack2 1.9.12

JackFreewheelDriver.cpp
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004-2008 Grame
4
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.
9
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.
14
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.
18
19 */
20
21 #include "JackSystemDeps.h"
22 #include "JackFreewheelDriver.h"
23 #include "JackEngineControl.h"
24 #include "JackLockedEngine.h"
25
26 namespace Jack
27 {
28
29 // When used in "master" mode
30
31 int JackFreewheelDriver::Process()
32 {
33 jack_log("JackFreewheelDriver::Process master %lld", fEngineControl->fTimeOutUsecs);
34 JackDriver::CycleTakeBeginTime();
35
36 if (fEngine->Process(fBeginDateUst, fEndDateUst)) {
37
38 // Resume connected clients in the graph
39 if (ResumeRefNum() < 0) {
40 jack_error("JackFreewheelDriver::Process: ResumeRefNum error");
41 }
42
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");
46 }
47
48 } else { // Graph not finished: do not activate it
49 jack_error("JackFreewheelDriver::Process: Process error");
50 }
51
52 return 0;
53 }
54
55 // When used in "slave" mode
56
57 int JackFreewheelDriver::ProcessReadSync()
58 {
59 // Resume connected clients in the graph
60 if (ResumeRefNum() < 0) { // Signal all clients
61 jack_error("JackFreewheelDriver::ProcessReadSync: ResumeRefNum error");
62 return -1;
63 }
64 return 0;
65 }
66
67 int JackFreewheelDriver::ProcessWriteSync()
68 {
69 // Generic "SuspendRefNum" here
70 if (JackDriver::SuspendRefNum() < 0) {
71 jack_error("JackFreewheelDriver::ProcessSync: SuspendRefNum error");
72 return -1;
73 }
74 return 0;
75 }
76
77 int JackFreewheelDriver::ProcessReadAsync()
78 {
79 // Resume connected clients in the graph
80 if (ResumeRefNum() < 0) { // Signal all clients
81 jack_error("JackFreewheelDriver::ProcessReadAsync: ResumeRefNum error");
82 return -1;
83 }
84 return 0;
85 }
86
87 int JackFreewheelDriver::ProcessWriteAsync()
88 {
89 return 0;
90 }
91
92 int JackFreewheelDriver::SuspendRefNum()
93 {
94 return fGraphManager->SuspendRefNum(&fClientControl, fSynchroTable, FREEWHEEL_DRIVER_TIMEOUT * 1000000);
95 }
96
97 } // end of namespace
jack_log
SERVER_EXPORT void jack_log(const char *fmt,...)
Definition: JackError.cpp:108
jack_error
SERVER_EXPORT void jack_error(const char *fmt,...)
Definition: JackError.cpp:92